I have a static website where I want to create a redirection depending on the browser language. The website runs in a docker using nginx and is built as follows:
nginx.conf:
user nginx;
worker_processes 4;
error_log /dev/stderr info;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /dev/stdout;
sendfile on;
keepalive_timeout 65;
include /etc/nginx/conf.d/*.conf;
root /usr/share/nginx/my-app;
map $http_accept_language $myindex {
default index.html;
~*^fr.* index.fr.html;
}
server {
location / {
rewrite .* $myindex;
}
}
}
default.conf:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /var/www;
index index.html;
location / {
try_files $uri $uri/ /index.html$is_args$args;
}
}
dockerfile
# nginx
FROM nginx:1.17.5-alpine
COPY src /var/www
COPY nginx.conf /etc/nginx/nginx.conf
COPY conf.d /etc/nginx/conf.d
EXPOSE 80
As soon as I go to the localhost the following problem occurs: en -> index.html en -> index.html (Expected: index.de.html)