From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id 6DCiAyIcQmDRSQAA0tVLHw (envelope-from ) for ; Fri, 05 Mar 2021 11:55:14 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id OBodOyEcQmBvYAAAB5/wlQ (envelope-from ) for ; Fri, 05 Mar 2021 11:55:13 +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 8F60519F69 for ; Fri, 5 Mar 2021 12:55:12 +0100 (CET) Received: from localhost ([::1]:34782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lI931-0004Q1-0u for larch@yhetil.org; Fri, 05 Mar 2021 06:55:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36898) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lI92s-0004OG-89 for bug-guix@gnu.org; Fri, 05 Mar 2021 06:55:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49737) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lI92r-0002oW-SF for bug-guix@gnu.org; Fri, 05 Mar 2021 06:55:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lI92r-0004jM-Qt for bug-guix@gnu.org; Fri, 05 Mar 2021 06:55:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#46807: [website] return 404 with HTTP header 'Accept-Language: zh-CN, zh' Resent-From: "pelzflorian (Florian Pelz)" Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 05 Mar 2021 11:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46807 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 46807@debbugs.gnu.org Received: via spool by 46807-submit@debbugs.gnu.org id=B46807.161494529618169 (code B ref 46807); Fri, 05 Mar 2021 11:55:01 +0000 Received: (at 46807) by debbugs.gnu.org; 5 Mar 2021 11:54:56 +0000 Received: from localhost ([127.0.0.1]:33050 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lI92m-0004iz-21 for submit@debbugs.gnu.org; Fri, 05 Mar 2021 06:54:56 -0500 Received: from pelzflorian.de ([5.45.111.108]:36202 helo=mail.pelzflorian.de) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lI92j-0004iq-GK for 46807@debbugs.gnu.org; Fri, 05 Mar 2021 06:54:54 -0500 Received: from pelzflorian.localdomain (unknown [5.45.111.108]) by mail.pelzflorian.de (Postfix) with ESMTPSA id 0201F3605E2; Fri, 5 Mar 2021 12:54:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=pelzflorian.de; s=mail; t=1614945292; bh=Cke5+mGBgBMEGTtYoQ9kH+pMf+mQOoVFryBhxF5MQMo=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=NcsccEEgbCo9DnrncnBMH6+skh8OoVuT6fj/H8Kbsfu1PRZVpseRa5uw27qitDIYN w33XgJAoQIB01n0OE5XyEA23+33qyoKrpkO/IIhih77dJHyrub4XWXpv2k2XNgexz3 EaY2iVIPvaJSdgKCeCyhFMEANmomLwKjZYSRbsR0= Date: Fri, 5 Mar 2021 12:54:42 +0100 From: "pelzflorian (Florian Pelz)" Message-ID: <20210305115333.prvjomh2lre7rt5k@pelzflorian.localdomain> References: <87im6btcfw.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="xchv4mmsgprrdcjj" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87im6btcfw.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -0.36 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=pelzflorian.de header.s=mail header.b=NcsccEEg; dmarc=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 8F60519F69 X-Spam-Score: -0.36 X-Migadu-Scanner: scn0.migadu.com X-TUID: fnGeH7lmgwHD --xchv4mmsgprrdcjj Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hello all, On Mon, Mar 01, 2021 at 11:06:59AM +0100, Ludovic Courtès wrote: > Florian, could it be that we’re not normalizing language tags > appropriately? Does that ring a bell? The attached patch to maintenance.git fixes the remaining minor issue: Now Accept-Language language codes get normalized, zh to zh-CN, so web browsers requesting any kind of Chinese get the website in mainland Chinese. (This is a minor issue. The only valid URL is /zh-CN/ since my last patch to guix-artwork because I don’t know how to rewrite/redirect URLs in nginx.) The patch was tested on a berlin VM. There is no copyright header in maintenance.git’s hydra/nginx/berlin.scm so I did not add a copyright. I hereby license the patch CC0 . Shall I just push? A reconfigure of berlin will be necessary but is not urgent. Regards, Florian --xchv4mmsgprrdcjj Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0001-nginx-berlin-Normalize-Accept-Language-language-code.patch" From: Florian Pelz Date: Thu, 4 Mar 2021 20:29:27 +0100 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [PATCH] nginx: berlin: Normalize Accept-Language language code zh to zh-CN. Now web browsers requesting any kind of Chinese get the website in mainland Chinese. zh, zh-Hans, zh-Hans-CN all are synonymous with zh-CN now. * hydra/nginx/berlin.scm (accept-languages): New procedure. (%extra-content): Normalize $lang variable with it. --- hydra/nginx/berlin.scm | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/hydra/nginx/berlin.scm b/hydra/nginx/berlin.scm index 85aaf38..4b9d297 100644 --- a/hydra/nginx/berlin.scm +++ b/hydra/nginx/berlin.scm @@ -995,12 +995,37 @@ PUBLISH-URL." (uri "~ /(.*)") (body (list "return 301 $scheme://guixwl.org/$1;")))))))) +(define (accept-languages language-lists) + "Returns nginx configuration code to set up the $lang variable +according to the Accept-Language header in the HTTP request. The +requesting user agent will be served the files at /$lang/some/url. +Each list in LANGUAGE-LISTS starts with the $lang and is followed by +synonymous IETF language tags that should be mapped to the same $lang." + (define (language-mappings language-list) + (define (language-mapping language) + (string-join (list " " language (car language-list) ";"))) + (string-join (map language-mapping language-list) "\n")) + + (let ((directives + `(,(string-join + `("set_from_accept_language $lang_unmapped" + ,@(map string-join language-lists) + ";")) + "map $lang_unmapped $lang {" + ,@(map language-mappings language-lists) + "}"))) + (string-join directives "\n"))) + (define %extra-content (list "default_type application/octet-stream;" "sendfile on;" - "set_from_accept_language $lang en de es fr zh-CN;" + (accept-languages '(("en") + ("de") + ("es") + ("fr") + ("zh-CN" "zh" "zh-Hans" "zh-Hans-CN"))) ;; Maximum chunk size to send. Partly this is a workaround for ;; , but also the nginx docs mention that -- 2.30.1 --xchv4mmsgprrdcjj--