From ef1d268cd75219c18ef098389a8ea5ef460ee542 Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Tue, 8 Oct 2019 08:30:59 +0200 Subject: [PATCH] berlin: Redirect to localized website depending on Accept-Language header. * hydra/nginx/berlin.scm (guix.gnu.org-locations): Redirect html URLs. (%nginx-configuration): Load required nginx dynamic module. --- hydra/nginx/berlin.scm | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm index df90873..c716103 100644 --- a/hydra/nginx/berlin.scm +++ b/hydra/nginx/berlin.scm @@ -1,6 +1,7 @@ ;; Nginx configuration for ci.guix.info -(use-modules (gnu services web)) +(use-modules (gnu packages web-xyz) + (gnu services web)) ;; TODO: these settings cannot currently expressed with Guix: @@ -462,6 +463,16 @@ PUBLISH-URL." (nginx-location-configuration (uri "~ \\.pdf$") ;*.pdf at the top level (body (list "root /srv/guix-pdfs;"))) + (nginx-location-configuration + (uri "~ (.*)/$") + (body (list + "try_files $1/index.html =404;"))) + (nginx-location-configuration + (uri "~ (.html|.htm)$") + (body (list + ;; put en first so it is the default: + "set_from_accept_language $lang en de;" + "try_files /$lang/$uri $uri =404;"))) (nginx-location-configuration ;certbot (uri "/.well-known") @@ -758,5 +769,11 @@ PUBLISH-URL." (define %nginx-configuration (nginx-configuration (server-blocks %berlin-servers) + (load-modules + (list + ;; We need this module for redirecting users to the localized + ;; website of their choice. + (file-append nginx-mod-accept-language "\ +/etc/nginx/modules/ngx_http_accept_language_module.so"))) (extra-content (string-join %extra-content "\n")))) -- 2.23.0