Last active
July 6, 2023 15:32
-
-
Save alex-arriaga/da5cf14bd96dd070323b109f47714f98 to your computer and use it in GitHub Desktop.
Nginx sample configuration for an Angular Multilingual application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This file should be linked into the "sites-enabled" directory in your Nginx installation: