From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id wI+qBb7352B88QAAgWs5BA (envelope-from ) for ; Fri, 09 Jul 2021 09:16:14 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id qHtJAb7352DuQwAAB5/wlQ (envelope-from ) for ; Fri, 09 Jul 2021 07:16:14 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 061EA1E2EA for ; Fri, 9 Jul 2021 09:16:13 +0200 (CEST) Received: from localhost ([::1]:44666 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m1kk7-0008HY-WE for larch@yhetil.org; Fri, 09 Jul 2021 03:16:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m1kjy-0008EH-CV for guix-patches@gnu.org; Fri, 09 Jul 2021 03:16:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46696) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m1kjy-0007nl-4a for guix-patches@gnu.org; Fri, 09 Jul 2021 03:16:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m1kjx-0006uU-NO for guix-patches@gnu.org; Fri, 09 Jul 2021 03:16:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49431] [PATCH maintenance.git] nginx: berlin: Redirect old video URLs for each language. Resent-From: "pelzflorian (Florian Pelz)" Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 09 Jul 2021 07:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49431 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 49431@debbugs.gnu.org, Luis Felipe Received: via spool by 49431-submit@debbugs.gnu.org id=B49431.162581491726504 (code B ref 49431); Fri, 09 Jul 2021 07:16:01 +0000 Received: (at 49431) by debbugs.gnu.org; 9 Jul 2021 07:15:17 +0000 Received: from localhost ([127.0.0.1]:58242 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1kjF-0006tQ-82 for submit@debbugs.gnu.org; Fri, 09 Jul 2021 03:15:17 -0400 Received: from pelzflorian.de ([5.45.111.108]:57422 helo=mail.pelzflorian.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m1kjB-0006tF-O2 for 49431@debbugs.gnu.org; Fri, 09 Jul 2021 03:15:16 -0400 Received: from pelzflorian.localdomain (unknown [5.45.111.108]) by mail.pelzflorian.de (Postfix) with ESMTPSA id 9005A360672; Fri, 9 Jul 2021 09:15:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pelzflorian.de; s=mail; t=1625814912; bh=7HhYRIU+IxGXGoN33KEQoE4Flagtcc85ZEGKlKycZEA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=IIPQMVpYJM572F1W+vg/xMrRE6o/HzUnHMzBJX7HSqhg/y3R/Bhs+fXuFA62n0jZS FAVWjFNSPyX3KDZPzpMPmjiZfMCHGdR3JRiGzsKRTtCpIgELK5hU7XeYlJVWSRIMpu 5nlZLqlIGKoCn8o+v0PKBirjT1zFRSf5Bb99pgC0= Date: Fri, 9 Jul 2021 09:15:04 +0200 From: "pelzflorian (Florian Pelz)" Message-ID: <20210709070715.235m7qs3gicmms4w@pelzflorian.localdomain> References: <20210706065304.6kqbwqlcf6calkh7@pelzflorian.localdomain> <87a6mwlxo3.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="iookygiwihals7w7" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87a6mwlxo3.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1625814973; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/PHiH3fbiJ3eQlc6SPpGtksg+4Z9MomEU1mZg8B18TE=; b=kCtPUIExtxvlvzjapLGsttSXeHUHyo3uj/PZgAXNj2LyGa05zRP55dt251ZAwWTPqhS/Sn Or+NptOdGlBSBg9r6KhcsO20/bCsa5130/W8eKvuhTW8sRbVcI4gS5FXpmKniSwEEV7txz W+nQqvAwY0qyuludHTfEQc5J/biqhqyKcngi+Vgy0hav3KfTGlTUCSmwha8VaaW1lIb21C ygXcqpf28TSJ6QMvS7EjrxCY277rQ1lkwRSO/J/xq1xZ2fJeJl7g7p+Te26XwrVeJFSqPB QrHhOsl1ZctrHc0K5f6AJtexYD/xvz2kp0jR8g4o/SmmtokOlj6WigYWSK3p9w== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625814973; a=rsa-sha256; cv=none; b=ZhAD1H7BW4fI/OZSDZhqp2m+XtniG98LbnMxDH5NQ1oqYEKP2+w2s1nxwoVnNhMCJksreE dydzu3N+L1BWWL6FX7QYcuDV0nz53+yk8gVBwJQqrEWlsa5bKQtMF8Qk7eYIsCsVNEq2ni 31dPM1OImlF6jnF1uDqsNNFcpPlG8z+AzIwVe0/j0MtiVD1hEbtKE9jPDhAEMVUEZP6uyK hGAkUd2nDLYUcbuzFPTy/WIi4zU7NMdlCdv6kYjzRUHwhwszKJGyCUQOxNTGMFF3+8d1Db eKQgArvlBnn+g0k83l3GK5xKWSGiuyNFVDjvnNyUs5WnCs2Fxgo7re9qA4nNiQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=pelzflorian.de header.s=mail header.b=IIPQMVpY; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -0.40 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=pelzflorian.de header.s=mail header.b=IIPQMVpY; dmarc=none; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: 061EA1E2EA X-Spam-Score: -0.40 X-Migadu-Scanner: scn1.migadu.com X-TUID: JSTV+PfPKM4J --iookygiwihals7w7 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Thank you two for your opinion, Luis and Ludo. On Thu, Jul 08, 2021 at 03:53:16PM +0200, Ludovic Courtès wrote: > Shouldn’t we also redirect > > /$lang/videos/everyday-use-of-gnu-guix,-part-one/ -> /$lang/videos/2020/everyday-use-of-gnu-guix-part-one/ > > since the left-hand side here was the right-hand side of the previous > redirects? Each valid $lang was handled further down, but my patch was confusing, especially when somebody wants to add more redirections. Find attached a revised patch with per-language redirection in only one place, namely new procedure `guix.gnu.org-redirects-for-each-language'. Do I need to add a copyright header? I hereby license/declare my patch CC0 . In the previous patch I had missed some cases without /LANG like /videos/everyday-use-of-gnu-guix,-part-one/index.html -> /$lang/videos/2020/everyday-use-of-gnu-guix-part-one/ Redirecting was unnecessary for /videos/everyday-use-of-gnu-guix,-part-one/ -> /$lang/videos/2020/everyday-use-of-gnu-guix-part-one/ which already gets taken care of by /videos/everyday-use-of-gnu-guix,-part-one -> /$lang/videos/2020/everyday-use-of-gnu-guix-part-one/ thanks to nginx location normalization. Shall I push and then wait until someone guix system reconfigures berlin? Regards, Florian --iookygiwihals7w7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="nginx-berlin-Redirect-old-video-URLs-for-each-language-v2.patch" >From f07c22a4a8a26a203f3bf27f619d023d4c668cf3 Mon Sep 17 00:00:00 2001 From: Florian Pelz Date: Fri, 9 Jul 2021 07:11:00 +0200 Subject: [PATCH] nginx: berlin: Redirect old video URLs for each language. * hydra/nginx/berlin.scm (languages-to-accept): New list. Move here the languages list from ... (%extra-content) ... here. Use languages from 'languages-to-accept'. (guix.gnu.org-redirects-for-each-language): New procedure. Add new video redirections. (guix.gnu.org-redirect-locations): New list. Move here the old redirections. (guix.gnu.org-other-locations): New list. Move here the other nginx locations from ... (guix.gnu.org-locations): ... here. Reimplement in terms of the above. --- hydra/nginx/berlin.scm | 91 +++++++++++++++++++++++++++++++++--------- 1 file changed, 72 insertions(+), 19 deletions(-) diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm index 443294e..912024d 100644 --- a/hydra/nginx/berlin.scm +++ b/hydra/nginx/berlin.scm @@ -188,7 +188,7 @@ PUBLISH-URL." (body (list "root /var/www/guix;")))))) -(define guix.gnu.org-locations +(define guix.gnu.org-redirect-locations (list ;; Short URL for the installation script (redirect "/install.sh" "https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh") @@ -688,15 +688,71 @@ PUBLISH-URL." (redirect "/screenshots/virtual-machine" "/$lang/screenshots/virtual-machine/") (redirect "/screenshots/xfce" "/$lang/screenshots/xfce/") (redirect "/security" "/$lang/security/") - (redirect "/videos" "/$lang/videos/") - (redirect "/videos/asking-for-help" "/$lang/videos/asking-for-help/") - (redirect "/videos/everyday-use-of-gnu-guix,-part-one" "/$lang/videos/everyday-use-of-gnu-guix,-part-one/") - (redirect "/videos/everyday-use-of-gnu-guix,-part-two" "/$lang/videos/everyday-use-of-gnu-guix,-part-two/") - (redirect "/videos/installation-from-script" "/$lang/videos/installation-from-script/") - (redirect "/videos/packaging,-part-one" "/$lang/videos/packaging,-part-one/") - (redirect "/videos/packaging,-part-two" "/$lang/videos/packaging,-part-two/") - (redirect "/videos/packaging,-part-three" "/$lang/videos/packaging,-part-three/") - + (redirect "/videos" "/$lang/videos/"))) + +(define languages-to-accept + ;; List of languages for redirection; see 'accept-languages' further + ;; below. + '(("en") + ("de") + ("eo") + ("es") + ("fr") + ("ko") + ("ru") + ("sk") + ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN"))) + +(define (guix.gnu.org-redirects-for-each-language) + ;; These old URL request paths existed in many forms; without /LANG + ;; in front and with /LANG in front for each language. Redirect + ;; each of them. + (define redirections + (list + (cons "/videos/everyday-use-of-gnu-guix,-part-one" "/videos/2020/everyday-use-of-gnu-guix-part-one/") + (cons "/videos/everyday-use-of-gnu-guix,-part-two" "/videos/2020/everyday-use-of-gnu-guix-part-two/") + (cons "/videos/system-graphical-installer" "/videos/2020/system-graphical-installer/") + (cons "/videos/asking-for-help" "/videos/2020/asking-for-help/") + (cons "/videos/installation-from-script" "/videos/2020/installation-from-script/") + (cons "/videos/packaging,-part-one" "/videos/2020/packaging-part-one/") + (cons "/videos/packaging,-part-two" "/videos/2020/packaging-part-two/") + (cons "/videos/packaging,-part-three" "/videos/2020/packaging-part-three/"))) + + (define (redirect-directory old new) + ;; Match nginx' behavior that request URLs with suffix "", "/" + ;; "/index.html" lead to the same file. The suffix "/" is not taken + ;; care of here because it already gets normalized by nginx location + ;; handling. The URLs in 'guix.gnu.org-redirect-locations' do not + ;; need this treatment, because they get an /index.html suffix + ;; through rewriting. + (let ((old-with-slashes-trimmed (string-trim-right old #\/))) + (list + (redirect old-with-slashes-trimmed new) + (redirect (string-append old-with-slashes-trimmed "/index.html") new)))) + + (define (guix.gnu.org-redirect-locations-for-lang lang) + (define (redirect-lang old new) + (redirect-directory (string-append "/" lang old) + (string-append "/" lang new))) + (append-map redirect-lang (map car redirections) (map cdr redirections))) + + (append + ;; Now all needed redirections are: + ;; + ;; 1) those without /LANG/ in front get redirected to /$lang/ + (append-map redirect-directory + (map car redirections) ;old URLs without /LANG + ;; new URLs with /$lang prepended: + (map (compose (lambda (new-without-lang) + (string-append "/$lang" new-without-lang)) + cdr) + redirections)) + ;; 2) those with /LANG/ in front get redirected to the same /LANG/ + (append-map guix.gnu.org-redirect-locations-for-lang + (map car languages-to-accept)))) + +(define guix.gnu.org-other-locations + (list (nginx-location-configuration (uri "/guix-videos") (body (list "alias /srv/videos;"))) @@ -754,6 +810,11 @@ PUBLISH-URL." (uri "/.well-known") (body (list "root /var/www;"))))) +(define guix.gnu.org-locations + (append guix.gnu.org-redirect-locations + (guix.gnu.org-redirects-for-each-language) + guix.gnu.org-other-locations)) + (define %publish-url "http://localhost:3000") (define %berlin-servers @@ -1033,15 +1094,7 @@ synonymous IETF language tags that should be mapped to the same $lang." "default_type application/octet-stream;" "sendfile on;" - (accept-languages '(("en") - ("de") - ("eo") - ("es") - ("fr") - ("ko") - ("ru") - ("sk") - ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN"))) + (accept-languages languages-to-accept) ;; Maximum chunk size to send. Partly this is a workaround for ;; , but also the nginx docs mention that -- 2.32.0 --iookygiwihals7w7--