Skip to content

Commit

Permalink
feat: update nginx.conf for deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
WeihanLi committed Nov 19, 2023
1 parent b6b5631 commit 25795fe
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions conf/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ http {
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

# Browser preferred language detection (does NOT require AcceptLanguageModule)
map $http_accept_language $accept_language {
~*^zh zh;
~*^en en;
}

access_log off;
log_not_found off;
sendfile on;
Expand All @@ -28,6 +34,19 @@ http {
location / {
root /usr/share/nginx/html;

# Fallback to default language if no preference defined by browser
if ($accept_language ~ "^$") {
set $accept_language "fr";
}
# Redirect "/" to Angular application in the preferred language of the browser
rewrite ^/$ /$accept_language permanent;

# Everything under the Angular application is always redirected to Angular in the
# correct language
location ~ ^/(zh|en) {
try_files $uri /$1/index.html?$args;
}

index index.html;
try_files $uri $uri/ /index.html;

Expand Down

0 comments on commit 25795fe

Please sign in to comment.