Last active
May 22, 2022 19:49
-
-
Save codebanesr/539df89d84c29c43137a3ae552faf8d5 to your computer and use it in GitHub Desktop.
Nginx test configuration
This file contains 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
gzip on; | |
gzip_types text/plain text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml; | |
# Browser preferred language detection (does NOT require AcceptLanguageModule) | |
map $http_accept_language $accept_language { | |
default en; | |
~*^en en; | |
~*^ar ar; | |
} | |
# ... | |
server { | |
listen 80; | |
listen [::]:80; | |
server_name localhost; | |
root /usr/share/nginx/html; | |
index index.html; | |
# Fallback to default language if no preference defined by browser | |
# if ($accept_language ~ "^$") { | |
# set $accept_language "en"; | |
#} | |
# Redirect "/" to Angular app in browser's preferred language | |
#rewrite ^/$ /$accept_language permanent; | |
location / { | |
return 302 /$accept_language/; | |
} | |
location ~^/en { | |
try_files $uri $uri/ /en/index.html; | |
} | |
location ~^/ar { | |
try_files $uri $uri/ /ar/index.html; | |
} | |
# Everything under the Angular app is always redirected to Angular in the correct language | |
#location ~ ^/(en|ar) { | |
# index index.html index.htm; | |
# try_files $uri /$1/index.html =404; | |
# } | |
# ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment