Subject: bug#26302: Deploying the i18n’d web site

From: "pelzflorian (Florian Pelz)" <[email-masked]>
Date: Thu, 9 Apr 2020 16:57:30 +0200

On Thu, Apr 09, 2020 at 09:45:50AM +0200, pelzflorian (Florian Pelz) wrote:
> It seems redirects broke like
> 
> http://guix.gnu.org/news/gnu-dmd-01-released.html
> 
> on my test VM. :/

This seems to be fixed by using the attached patch instead.

I have not recreated the berlin test VM yet though, only edited
nginx.conf.

Regards,
Florian
diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm
index 303fd35..ff62fec 100644
--- a/hydra/nginx/berlin.scm
+++ b/hydra/nginx/berlin.scm
@@ -195,73 +195,73 @@ PUBLISH-URL."
    ;; What follows is a list of redirects for URLs that used to be
    ;; available at gnu.org/s/guix--e.g.,
    ;; <http://gnu.org/s/guix/news/porting-guix-and-guixsd.html>.
-   (redirect "/news/feed.xml" "/feeds/blog.atom")
-   (redirect "/news/porting-guix-and-guixsd.html" "/blog/2015/porting-guix-and-guixsd")
-   (redirect "/news/gnu-guix-welcomes-three-students-for-gsoc.html" "/blog/2015/gnu-guix-welcomes-three-students-for-gsoc")
-   (redirect "/news/gnu-guix-recruits-for-gsoc.html" "/blog/2015/gnu-guix-recruits-for-gsoc")
-   (redirect "/news/one-week-to-fosdem.html" "/blog/2014/one-week-to-fosdem")
-   (redirect "/news/gnu-dmd-02-released.html" "/blog/2014/gnu-dmd-02-released")
-   (redirect "/news/emacs-as-a-general-purpose-package-manager.html" "/blog/2014/emacs-as-a-general-purpose-package-manager")
-   (redirect "/news/join-gnu-guix-for-gsoc-2017.html" "/blog/2017/join-gnu-guix-for-gsoc-2017")
-   (redirect "/news/gnu-guix-05-released.html" "/blog/2013/gnu-guix-05-released")
-   (redirect "/news/guix-at-the-2014-gnu-hackers-meeting.html" "/blog/2014/guix-at-the-2014-gnu-hackers-meeting")
-   (redirect "/news/state-of-aarch64-on-guix.html" "/blog/2017/state-of-aarch64-on-guix")
-   (redirect "/news/coming-events.html" "/blog/2017/coming-events")
-   (redirect "/news/gnu-dmd-01-released.html" "/blog/2013/gnu-dmd-01-released")
-   (redirect "/news/announcing-guix-hpc.html" "/blog/2017/announcing-guix-hpc")
-   (redirect "/news/gnu-guix-looks-for-gsoc-students.html" "/blog/2014/gnu-guix-looks-for-gsoc-students")
-   (redirect "/news/guix-at-the-european-lisp-symposium.html" "/blog/2013/guix-at-the-european-lisp-symposium")
-   (redirect "/news/gnu-guix-08-released.html" "/blog/2014/gnu-guix-08-released")
-   (redirect "/news/gnu-guix-090-released.html" "/blog/2015/gnu-guix-090-released")
-   (redirect "/news/index.html" "/blog/")
-   (redirect "/news/gnu-guix-welcomes-four-students-for-gsoc.html" "/blog/2016/gnu-guix-welcomes-four-students-for-gsoc")
-   (redirect "/news/gnu-guix-081-released.html" "/blog/2015/gnu-guix-081-released")
-   (redirect "/news/timely-delivery-of-security-updates.html" "/blog/2016/timely-delivery-of-security-updates")
-   (redirect "/news/guix-at-openbio-codefest-2014.html" "/blog/2014/guix-at-openbio-codefest-2014")
-   (redirect "/news/gnu-guix-talk-in-boston-ma-usa-on-january-20th.html" "/blog/2016/gnu-guix-talk-in-boston-ma-usa-on-january-20th")
-   (redirect "/news/gnu-guix-at-fosdem.html" "/blog/2015/gnu-guix-at-fosdem")
-   (redirect "/news/gnu-guix-082-released.html" "/blog/2015/gnu-guix-082-released")
-   (redirect "/news/chris-webber-talks-about-guix-in-chicago-september-30th.html" "/blog/2015/chris-webber-talks-about-guix-in-chicago-september-30th")
-   (redirect "/news/back-from-the-gnu-hackers-meeting.html" "/blog/2013/back-from-the-gnu-hackers-meeting")
-   (redirect "/news/reproducible-build-summit-2nd-edition.html" "/blog/2016/reproducible-build-summit-2nd-edition")
-   (redirect "/news/gnu-guix-talk-in-rennes-france-november-9th.html" "/blog/2015/gnu-guix-talk-in-rennes-france-november-9th")
-   (redirect "/news/gnu-guix-01-released.html" "/blog/2013/gnu-guix-01-released")
-   (redirect "/news/guix-tox-talk-at-pyconfr-october-17th.html" "/blog/2015/guix-tox-talk-at-pyconfr-october-17th")
-   (redirect "/news/gnu-guix-and-guixsd-0.13.0-released.html" "/blog/2017/gnu-guix-and-guixsd-0.13.0-released")
-   (redirect "/news/guix-gets-cross-compilation-support.html" "/blog/2013/guix-gets-cross-compilation-support")
-   (redirect "/news/gnu-guix-06-released.html" "/blog/2014/gnu-guix-06-released")
-   (redirect "/news/meet-guix-at-fosdem.html" "/blog/2016/meet-guix-at-fosdem")
-   (redirect "/news/reproducible-and-user-controlled-software-environments-in-hpc-with-guix.html" "/blog/2015/reproducible-and-user-controlled-software-environments-in-hpc-with-guix")
-   (redirect "/news/container-provisioning-with-guix.html" "/blog/2015/container-provisioning-with-guix")
-   (redirect "/news/guixsd-system-tests.html" "/blog/2016/guixsd-system-tests")
-   (redirect "/news/gnu-guix--guixsd-0100-released.html" "/blog/2016/gnu-guix--guixsd-0100-released")
-   (redirect "/news/gnu-guix-and-guixsd-0110-released.html" "/blog/2016/gnu-guix-and-guixsd-0110-released")
-   (redirect "/news/boot-to-guile.html" "/blog/2013/boot-to-guile")
-   (redirect "/news/gnu-guix-talk-at-opentechsummit-berlin-may-14th.html" "/blog/2015/gnu-guix-talk-at-opentechsummit-berlin-may-14th")
-   (redirect "/news/running-system-services-in-containers.html" "/blog/2017/running-system-services-in-containers")
-   (redirect "/news/growing-our-build-farm.html" "/blog/2016/growing-our-build-farm")
-   (redirect "/news/distro-of-the-linux-based-gnu-system-ported-to-mips.html" "/blog/2013/distro-of-the-linux-based-gnu-system-ported-to-mips")
-   (redirect "/news/guix-at-libreplanet-2016.html" "/blog/2016/guix-at-libreplanet-2016")
-   (redirect "/news/guix--gsoc.html" "/blog/2013/guix--gsoc")
-   (redirect "/news/service-composition-in-guixsd.html" "/blog/2015/service-composition-in-guixsd")
-   (redirect "/news/creating-bundles-with-guix-pack.html" "/blog/2017/creating-bundles-with-guix-pack")
-   (redirect "/news/back-from-the-european-lisp-symposium.html" "/blog/2013/back-from-the-european-lisp-symposium")
-   (redirect "/news/gnu-guix-04-released-happy-birthday-gnu.html" "/blog/2013/gnu-guix-04-released-happy-birthday-gnu")
-   (redirect "/news/reproducible-builds-a-status-update.html" "/blog/2017/reproducible-builds-a-status-update")
-   (redirect "/news/gnu-guix-083-released.html" "/blog/2015/gnu-guix-083-released")
-   (redirect "/news/join-gnu-guix-for-gsoc.html" "/blog/2016/join-gnu-guix-for-gsoc")
-   (redirect "/news/gnu-guix-and-guixsd-0120-released.html" "/blog/2016/gnu-guix-and-guixsd-0120-released")
-   (redirect "/news/meet-guix-at-fosdem-2017.html" "/blog/2017/meet-guix-at-fosdem-2017")
-   (redirect "/news/join-guix-for-an-on-line-hackathon-on-sep-28-29.html" "/blog/2013/join-guix-for-an-on-line-hackathon-on-sep-28-29")
-   (redirect "/news/gnome-in-guixsd.html" "/blog/2016/gnome-in-guixsd")
-   (redirect "/news/introducing-guix-a-package-manager-and-distro-for-gnu.html" "/blog/2012/introducing-guix-a-package-manager-and-distro-for-gnu")
-   (redirect "/news/gnu-guix-03-released.html" "/blog/2013/gnu-guix-03-released")
-   (redirect "/news/gnu-guix-07-released.html" "/blog/2014/gnu-guix-07-released")
-   (redirect "/news/gsoc-update.html" "/blog/2015/gsoc-update")
-   (redirect "/news/gnu-guix-02-released.html" "/blog/2013/gnu-guix-02-released")
-   (redirect "/news/guix-starts-fundraising-campaign-with-support-from-the-fsf.html" "/blog/2015/guix-starts-fundraising-campaign-with-support-from-the-fsf")
-   (redirect "/news/gnu-guix-ported-to-arm-and-other-niceties-of-the-new-year.html" "/blog/2015/gnu-guix-ported-to-arm-and-other-niceties-of-the-new-year")
-   (redirect "/news/reproducible-builds-a-means-to-an-end.html" "/blog/2015/reproducible-builds-a-means-to-an-end")
+   (redirect "/news/feed.xml" "/$lang/feeds/blog.atom")
+   (redirect "/news/porting-guix-and-guixsd.html" "/$lang/blog/2015/porting-guix-and-guixsd")
+   (redirect "/news/gnu-guix-welcomes-three-students-for-gsoc.html" "/$lang/blog/2015/gnu-guix-welcomes-three-students-for-gsoc")
+   (redirect "/news/gnu-guix-recruits-for-gsoc.html" "/$lang/blog/2015/gnu-guix-recruits-for-gsoc")
+   (redirect "/news/one-week-to-fosdem.html" "/$lang/blog/2014/one-week-to-fosdem")
+   (redirect "/news/gnu-dmd-02-released.html" "/$lang/blog/2014/gnu-dmd-02-released")
+   (redirect "/news/emacs-as-a-general-purpose-package-manager.html" "/$lang/blog/2014/emacs-as-a-general-purpose-package-manager")
+   (redirect "/news/join-gnu-guix-for-gsoc-2017.html" "/$lang/blog/2017/join-gnu-guix-for-gsoc-2017")
+   (redirect "/news/gnu-guix-05-released.html" "/$lang/blog/2013/gnu-guix-05-released")
+   (redirect "/news/guix-at-the-2014-gnu-hackers-meeting.html" "/$lang/blog/2014/guix-at-the-2014-gnu-hackers-meeting")
+   (redirect "/news/state-of-aarch64-on-guix.html" "/$lang/blog/2017/state-of-aarch64-on-guix")
+   (redirect "/news/coming-events.html" "/$lang/blog/2017/coming-events")
+   (redirect "/news/gnu-dmd-01-released.html" "/$lang/blog/2013/gnu-dmd-01-released")
+   (redirect "/news/announcing-guix-hpc.html" "/$lang/blog/2017/announcing-guix-hpc")
+   (redirect "/news/gnu-guix-looks-for-gsoc-students.html" "/$lang/blog/2014/gnu-guix-looks-for-gsoc-students")
+   (redirect "/news/guix-at-the-european-lisp-symposium.html" "/$lang/blog/2013/guix-at-the-european-lisp-symposium")
+   (redirect "/news/gnu-guix-08-released.html" "/$lang/blog/2014/gnu-guix-08-released")
+   (redirect "/news/gnu-guix-090-released.html" "/$lang/blog/2015/gnu-guix-090-released")
+   (redirect "/news/index.html" "/$lang/blog/")
+   (redirect "/news/gnu-guix-welcomes-four-students-for-gsoc.html" "/$lang/blog/2016/gnu-guix-welcomes-four-students-for-gsoc")
+   (redirect "/news/gnu-guix-081-released.html" "/$lang/blog/2015/gnu-guix-081-released")
+   (redirect "/news/timely-delivery-of-security-updates.html" "/$lang/blog/2016/timely-delivery-of-security-updates")
+   (redirect "/news/guix-at-openbio-codefest-2014.html" "/$lang/blog/2014/guix-at-openbio-codefest-2014")
+   (redirect "/news/gnu-guix-talk-in-boston-ma-usa-on-january-20th.html" "/$lang/blog/2016/gnu-guix-talk-in-boston-ma-usa-on-january-20th")
+   (redirect "/news/gnu-guix-at-fosdem.html" "/$lang/blog/2015/gnu-guix-at-fosdem")
+   (redirect "/news/gnu-guix-082-released.html" "/$lang/blog/2015/gnu-guix-082-released")
+   (redirect "/news/chris-webber-talks-about-guix-in-chicago-september-30th.html" "/$lang/blog/2015/chris-webber-talks-about-guix-in-chicago-september-30th")
+   (redirect "/news/back-from-the-gnu-hackers-meeting.html" "/$lang/blog/2013/back-from-the-gnu-hackers-meeting")
+   (redirect "/news/reproducible-build-summit-2nd-edition.html" "/$lang/blog/2016/reproducible-build-summit-2nd-edition")
+   (redirect "/news/gnu-guix-talk-in-rennes-france-november-9th.html" "/$lang/blog/2015/gnu-guix-talk-in-rennes-france-november-9th")
+   (redirect "/news/gnu-guix-01-released.html" "/$lang/blog/2013/gnu-guix-01-released")
+   (redirect "/news/guix-tox-talk-at-pyconfr-october-17th.html" "/$lang/blog/2015/guix-tox-talk-at-pyconfr-october-17th")
+   (redirect "/news/gnu-guix-and-guixsd-0.13.0-released.html" "/$lang/blog/2017/gnu-guix-and-guixsd-0.13.0-released")
+   (redirect "/news/guix-gets-cross-compilation-support.html" "/$lang/blog/2013/guix-gets-cross-compilation-support")
+   (redirect "/news/gnu-guix-06-released.html" "/$lang/blog/2014/gnu-guix-06-released")
+   (redirect "/news/meet-guix-at-fosdem.html" "/$lang/blog/2016/meet-guix-at-fosdem")
+   (redirect "/news/reproducible-and-user-controlled-software-environments-in-hpc-with-guix.html" "/$lang/blog/2015/reproducible-and-user-controlled-software-environments-in-hpc-with-guix")
+   (redirect "/news/container-provisioning-with-guix.html" "/$lang/blog/2015/container-provisioning-with-guix")
+   (redirect "/news/guixsd-system-tests.html" "/$lang/blog/2016/guixsd-system-tests")
+   (redirect "/news/gnu-guix--guixsd-0100-released.html" "/$lang/blog/2016/gnu-guix--guixsd-0100-released")
+   (redirect "/news/gnu-guix-and-guixsd-0110-released.html" "/$lang/blog/2016/gnu-guix-and-guixsd-0110-released")
+   (redirect "/news/boot-to-guile.html" "/$lang/blog/2013/boot-to-guile")
+   (redirect "/news/gnu-guix-talk-at-opentechsummit-berlin-may-14th.html" "/$lang/blog/2015/gnu-guix-talk-at-opentechsummit-berlin-may-14th")
+   (redirect "/news/running-system-services-in-containers.html" "/$lang/blog/2017/running-system-services-in-containers")
+   (redirect "/news/growing-our-build-farm.html" "/$lang/blog/2016/growing-our-build-farm")
+   (redirect "/news/distro-of-the-linux-based-gnu-system-ported-to-mips.html" "/$lang/blog/2013/distro-of-the-linux-based-gnu-system-ported-to-mips")
+   (redirect "/news/guix-at-libreplanet-2016.html" "/$lang/blog/2016/guix-at-libreplanet-2016")
+   (redirect "/news/guix--gsoc.html" "/$lang/blog/2013/guix--gsoc")
+   (redirect "/news/service-composition-in-guixsd.html" "/$lang/blog/2015/service-composition-in-guixsd")
+   (redirect "/news/creating-bundles-with-guix-pack.html" "/$lang/blog/2017/creating-bundles-with-guix-pack")
+   (redirect "/news/back-from-the-european-lisp-symposium.html" "/$lang/blog/2013/back-from-the-european-lisp-symposium")
+   (redirect "/news/gnu-guix-04-released-happy-birthday-gnu.html" "/$lang/blog/2013/gnu-guix-04-released-happy-birthday-gnu")
+   (redirect "/news/reproducible-builds-a-status-update.html" "/$lang/blog/2017/reproducible-builds-a-status-update")
+   (redirect "/news/gnu-guix-083-released.html" "/$lang/blog/2015/gnu-guix-083-released")
+   (redirect "/news/join-gnu-guix-for-gsoc.html" "/$lang/blog/2016/join-gnu-guix-for-gsoc")
+   (redirect "/news/gnu-guix-and-guixsd-0120-released.html" "/$lang/blog/2016/gnu-guix-and-guixsd-0120-released")
+   (redirect "/news/meet-guix-at-fosdem-2017.html" "/$lang/blog/2017/meet-guix-at-fosdem-2017")
+   (redirect "/news/join-guix-for-an-on-line-hackathon-on-sep-28-29.html" "/$lang/blog/2013/join-guix-for-an-on-line-hackathon-on-sep-28-29")
+   (redirect "/news/gnome-in-guixsd.html" "/$lang/blog/2016/gnome-in-guixsd")
+   (redirect "/news/introducing-guix-a-package-manager-and-distro-for-gnu.html" "/$lang/blog/2012/introducing-guix-a-package-manager-and-distro-for-gnu")
+   (redirect "/news/gnu-guix-03-released.html" "/$lang/blog/2013/gnu-guix-03-released")
+   (redirect "/news/gnu-guix-07-released.html" "/$lang/blog/2014/gnu-guix-07-released")
+   (redirect "/news/gsoc-update.html" "/$lang/blog/2015/gsoc-update")
+   (redirect "/news/gnu-guix-02-released.html" "/$lang/blog/2013/gnu-guix-02-released")
+   (redirect "/news/guix-starts-fundraising-campaign-with-support-from-the-fsf.html" "/$lang/blog/2015/guix-starts-fundraising-campaign-with-support-from-the-fsf")
+   (redirect "/news/gnu-guix-ported-to-arm-and-other-niceties-of-the-new-year.html" "/$lang/blog/2015/gnu-guix-ported-to-arm-and-other-niceties-of-the-new-year")
+   (redirect "/news/reproducible-builds-a-means-to-an-end.html" "/$lang/blog/2015/reproducible-builds-a-means-to-an-end")
    (redirect "/manual/html_node/Substitutes.html" "../en/html_node/Substitutes.html")
    (redirect "/manual/html_node/GNU-Free-Documentation-License.html" "../en/html_node/GNU-Free-Documentation-License.html")
    (redirect "/manual/html_node/The-Store-Monad.html" "../en/html_node/The-Store-Monad.html")
@@ -468,6 +468,10 @@ PUBLISH-URL."
     (uri "/guix")
     (body (list "root /var/www;")))
 
+   (nginx-location-configuration
+    (uri "~ (.html|.htm)$")
+    (body (list "try_files /$lang/$uri $uri =404;")))
+
    (nginx-location-configuration                  ;certbot
     (uri "/.well-known")
     (body (list "root /var/www;")))))
@@ -514,6 +518,7 @@ PUBLISH-URL."
     (locations guix.gnu.org-locations)
     (raw-content
      (list
+      "rewrite (.*)/$ $1/index.html;"
       "access_log /var/log/nginx/guix-info.access.log;")))
 
    (nginx-server-configuration
@@ -525,6 +530,7 @@ PUBLISH-URL."
      (append
       %tls-settings
       (list
+       "rewrite (.*)/$ $1/index.html;"
        "access_log /var/log/nginx/guix-info.https.access.log;"))))
 
    (nginx-server-configuration
@@ -621,6 +627,7 @@ PUBLISH-URL."
      (append
       %tls-settings
       (list
+       "rewrite (.*)/$ $1/index.html;"
        "access_log /var/log/nginx/guix-info.https.access.log;"))))
 
    (nginx-server-configuration
@@ -634,6 +641,7 @@ PUBLISH-URL."
      (append
       %tls-settings
       (list
+       "rewrite (.*)/$ $1/index.html;"
        "access_log /var/log/nginx/guix-gnu-org.https.access.log;"))))
 
    (nginx-server-configuration
@@ -717,6 +725,8 @@ PUBLISH-URL."
    "default_type  application/octet-stream;"
    "sendfile        on;"
 
+   "set_from_accept_language $lang en de;"
+
    ;; Maximum chunk size to send.  Partly this is a workaround for
    ;; <http://bugs.gnu.org/19939>, but also the nginx docs mention that
    ;; "Without the limit, one fast connection may seize the worker
@@ -775,6 +785,11 @@ PUBLISH-URL."
 (define %nginx-configuration
   (nginx-configuration
    (server-blocks %berlin-servers)
+   (modules
+    (list
+     ;; Module to redirect users to the localized pages of their choice.
+     (file-append nginx-accept-language-module
+                  "/etc/nginx/modules/ngx_http_accept_language_module.so")))
    (global-directives
     ;; This is a 72-core machine, but let's not use all of them for nginx.
     '((worker_processes . 16)