Add redirections to language subdirs
systems/xana.scm
21 | 21 | (use-modules (gnu services mcron)) | |
22 | 22 | (use-modules (gnu services networking)) | |
23 | 23 | (use-modules (gnu services web)) | |
24 | - | (use-modules (config certbot) (config cuirass) (config network) (config os)) | |
24 | + | (use-modules (config certbot) (config cuirass) (config network) (config os) (config web)) | |
25 | 25 | (use-modules (guix gexp)) | |
26 | 26 | (use-package-modules base compression gettext guile guile-xyz linux version-control | |
27 | 27 | wget) | |
28 | 28 | ||
29 | + | (define lepiller-policy | |
30 | + | (append | |
31 | + | web-base-policy | |
32 | + | '("# accept-language: en,en-US;q=0.8,ja;q=0.6" | |
33 | + | "set $first_language '';" | |
34 | + | "if ($http_accept_language ~* '(en|eo|fr)') {" | |
35 | + | " set $first_language $1;" | |
36 | + | "}" | |
37 | + | "if ($first_language = '') {" | |
38 | + | " set $first_language 'en';" | |
39 | + | "}" | |
40 | + | "set $my_uri $first_language/$uri;" | |
41 | + | "location ~ ^/[^/]*$ {" | |
42 | + | " return 301 /$first_language/$uri;" | |
43 | + | "}" | |
44 | + | ) | |
45 | + | (web-html-policy | |
46 | + | '(" try_files $my_uri $uri $uri/ =404;")) | |
47 | + | '("error_page 404 /404.html;"))) | |
48 | + | ||
29 | 49 | (define (makefile-job directory target packages env) | |
30 | 50 | #~(lambda () | |
31 | 51 | (define path | |
… | |||
115 | 135 | "/etc/letsencrypt/live/offlate.lepiller.eu/privkey.pem") | |
116 | 136 | (listen '("443 ssl http2" "[::]:443 ssl http2")) | |
117 | 137 | (server-name '("offlate.lepiller.eu")) | |
118 | - | (root "/srv/http/offlate/public")))) | |
138 | + | (root "/srv/http/offlate/public") | |
139 | + | (index '("index.html")) | |
140 | + | (try-files '("$uri" "$uri/" "=404")) | |
141 | + | (raw-content lepiller-policy)))) | |
119 | 142 | (simple-service 'i18n-http-server nginx-service-type | |
120 | 143 | (list (nginx-server-configuration | |
121 | 144 | (ssl-certificate |