diff --git a/containers/nginx/dev.conf b/containers/nginx/dev.conf index b0858f0888..6b095b08cc 100644 --- a/containers/nginx/dev.conf +++ b/containers/nginx/dev.conf @@ -1,3 +1,12 @@ +# Dynamic language redirection. +# Ensure that "en" is last, or people with, for instance, "fr en" will always default to "en". +map $http_accept_language $lang { + default en; + ~es es; + ~fr fr; + ~en en; +} + server { listen 80; listen [::]:80 default ipv6only=on; @@ -24,6 +33,11 @@ server { port_in_redirect off; } + # Redirect to the language directory specified by the user's browser via the Accept-Language header. + location ~ ^/$ { + return 301 $scheme://$http_host$1/$lang/; + } + location ~ ^(/api|/fs|/icon|/carousel) { add_header 'Access-Control-Allow-Origin' "$http_origin"; add_header 'Access-Control-Allow-Credentials' 'true'; @@ -98,4 +112,4 @@ server { log_not_found off; deny all; } -} \ No newline at end of file +} diff --git a/containers/nginx/minds.conf b/containers/nginx/minds.conf index baed6df5f7..51ae3df3f4 100644 --- a/containers/nginx/minds.conf +++ b/containers/nginx/minds.conf @@ -1,3 +1,12 @@ +# Dynamic language redirection. +# Ensure that "en" is last, or people with, for instance, "fr en" will always default to "en". +map $http_accept_language $lang { + default en; + ~es es; + ~fr fr; + ~en en; +} + server { listen 80; listen [::]:80 default ipv6only=on; @@ -25,6 +34,11 @@ server { port_in_redirect off; } + # Redirect to the language directory specified by the user's browser via the Accept-Language header. + location ~ ^/$ { + return 301 $scheme://$http_host$1/$lang/; + } + location ~ ^(/api|/fs|/icon|/carousel) { add_header Strict-Transport-Security "max-age=31536000; includeSubdomains; preload"; add_header 'Access-Control-Allow-Origin' "$http_origin";