Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx sample configuration for an Angular Multilingual application
server {
listen 80;
root /var/www/html/my-app/dist;
index index.html index.htm;
server_name angular-i18n.example.com www.angular-i18n.example.com;
location /en/ {
autoindex on;
try_files $uri$args $uri$args/ /en/index.html;
}
location /es/ {
autoindex on;
try_files $uri$args $uri$args/ /es/index.html;
}
# Default to EN
location / {
# Autoindex is disabled here + the $uri$args/ is missing from try_files
try_files $uri$args /en/index.html;
}
# REALLY important for JavaScript modules (type="module") to work as expected!!!
location ~ \.js {
add_header Content-Type text/javascript;
}
}
@alex-arriaga

This comment has been minimized.

Copy link
Owner Author

@alex-arriaga alex-arriaga commented Jun 25, 2019

This file should be linked into the "sites-enabled" directory in your Nginx installation:

sudo ln -s /etc/nginx/sites-available/angular-i18n.example.com /etc/nginx/sites-enabled/
sudo service nginx configtest
sudo service nginx reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.