Skip to content

Commit f4f4203

Browse files
committed
nginx: redirect to browser locale
1 parent b37d4bb commit f4f4203

File tree

1 file changed

+25
-14
lines changed

1 file changed

+25
-14
lines changed

module.nix

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,32 @@ in
3737

3838
services.nginx = {
3939
enable = true;
40+
commonHttpConfig = ''
41+
map $http_accept_language $accept_language {
42+
~*^de de;
43+
default en;
44+
}
45+
'';
4046

41-
virtualHosts."${cfg.domain}".locations = {
42-
"/" = {
43-
root = "${package}/browser";
44-
# just something that does not exists
45-
index = "X6XewZMsmreGIxx1lCdp0Yo1X4qHTivW";
46-
tryFiles = "$uri @website";
47-
extraConfig = ''
48-
expires max;
49-
access_log off;
50-
'';
51-
};
52-
"@website" = {
53-
recommendedProxySettings = true;
54-
proxyPass = "http://127.0.0.1:4000";
47+
virtualHosts."${cfg.domain}" = {
48+
extraConfig = ''
49+
rewrite ^/(?!de(?:/|$)|en(?:/|$))(.*)$ /$accept_language/$1 redirect;
50+
'';
51+
locations = {
52+
"/" = {
53+
root = "${package}/browser";
54+
# just something that does not exists
55+
index = "X6XewZMsmreGIxx1lCdp0Yo1X4qHTivW";
56+
tryFiles = "$uri @website";
57+
extraConfig = ''
58+
expires max;
59+
access_log off;
60+
'';
61+
};
62+
"@website" = {
63+
recommendedProxySettings = true;
64+
proxyPass = "http://127.0.0.1:4000";
65+
};
5566
};
5667
};
5768
};

0 commit comments

Comments
 (0)