From unknown Fri Jun 20 07:25:21 2025 X-Loop: help-debbugs@gnu.org Subject: bug#68610: URI path in git-http-nginx-location-configuration doesn't accept / properly Resent-From: Richard Sent Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sat, 20 Jan 2024 17:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 68610 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 68610@debbugs.gnu.org X-Debbugs-Original-To: bug-guix@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.170577115426585 (code B ref -1); Sat, 20 Jan 2024 17:20:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jan 2024 17:19:14 +0000 Received: from localhost ([127.0.0.1]:35568 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rREzy-0006uj-8N for submit@debbugs.gnu.org; Sat, 20 Jan 2024 12:19:14 -0500 Received: from lists.gnu.org ([2001:470:142::17]:40412) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rREzt-0006uK-92 for submit@debbugs.gnu.org; Sat, 20 Jan 2024 12:19:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rREzk-0003NG-Pa for bug-guix@gnu.org; Sat, 20 Jan 2024 12:19:00 -0500 Received: from mail-108-mta80.mxroute.com ([136.175.108.80]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rREzi-0005C7-Oo for bug-guix@gnu.org; Sat, 20 Jan 2024 12:19:00 -0500 Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta80.mxroute.com (ZoneMTA) with ESMTPSA id 18d27e1e0a30003727.001 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Sat, 20 Jan 2024 17:18:51 +0000 X-Zone-Loop: a1c1c5d71789c163c1a248a4fe274fcd7c74beb6c566 X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=freakingpenguin.com; s=x; h=Content-Type:MIME-Version:Message-ID:Date: Subject:To:From:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=n14Wgrw5uOzA/jUzQ3ACWw3v0KUkOnNy1RrSfgaaa1Y=; b=K4w7OIDp0C8XRHmio8Ei/IhM9T TGdWpjl09u447K5gR/CZThlu30X5u8U9izV87iP1wPk3vPnU0R4VxBrcbFsgmy3U5UiQ7kKBPg+/k YaZhdbbpbqySqM6pbbc1R+pslAKQuacqlmNskZnrn+R3I2kJA9SHKvG3NOHWOP68OJbdGS/KijdpO 9h3FWBK5gqbQuiFXG+BwTsSDWEofq6HEycqtwcEOSRNzzAqCqdUNIe7GopnK227YeUL5LpCdKfTk6 t5SC3L4bx7dcCQlWVxhPYVgcF1fqpOo3Yoix/QW8CFduDK/dcNAPPaSZExNNoF6biQAXZx9F1LvgJ yKq8VQ3Q==; From: Richard Sent Date: Sat, 20 Jan 2024 12:18:47 -0500 Message-ID: <87zfwzapoo.fsf@freakingpenguin.com> MIME-Version: 1.0 Content-Type: text/plain X-Authenticated-Id: richard@freakingpenguin.com Received-SPF: pass client-ip=136.175.108.80; envelope-from=richard@freakingpenguin.com; helo=mail-108-mta80.mxroute.com X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.9 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.1 (/) Hi all, In the documentation for Version Control Services, there is example code for sharing Git repos through Nginx, posted below. The line (git-http-configuration (uri-path "/")) implies that git repositories can be reached at "git.my-host.org/repo.git". However, this doesn't work. --8<---------------cut here---------------start------------->8--- (service nginx-service-type (nginx-configuration (server-blocks (list (nginx-server-configuration (listen '("443 ssl")) (server-name "git.my-host.org") (ssl-certificate "/etc/letsencrypt/live/git.my-host.org/fullchain.pem") (ssl-certificate-key "/etc/letsencrypt/live/git.my-host.org/privkey.pem") (locations (list (git-http-nginx-location-configuration (git-http-configuration (uri-path "/")))))))))) --8<---------------cut here---------------end--------------->8--- Nginx's location information is generated by git-http-nginx-location-configuration, which runs --8<---------------cut here---------------start------------->8--- (uri (string-append "~ /" (string-trim-both uri-path #\/) "(/.*)")) --8<---------------cut here---------------end--------------->8--- If uri-path is "/" (or "", or "\"), this entry will be created in nginx.conf: --8<---------------cut here---------------start------------->8--- location ~ /(/.*) { .... } --8<---------------cut here---------------end--------------->8--- This location regex pattern will match git.my-host.org//, but not git.my-host.org/. However, Nginx merges slashes by default, so you cannot access the repo with 'http://git.my-host.org//repo.git' because Nginx collapses that to http://git.my-host.org/repo.git before matching the URI against the location pattern. Which, as mentioned, does not match. I did find that (uri-path "*") does work, but I've not tested it extensively. I also found that I can add `(raw-content (list "merge_slashes off;"))` to nginx-server-configuration, then use `$ git clone http://git.my-host.org//repo.git`, but that's not ideal. At minimum, the documentation should be updated to reflect this (uri-path "/" vs "\" vs "" are identical). I don't know what the future plans are for git-http-service, but I can think of two possible solutions: 1. git-http-nginx-location-configuration no longer modifies uri-path and instead pastes it literally in nginx.conf. To my understanding "/git" would work identically without the regex match currently used, exposing repos at "host.domain/git/path/to/repo.git", but I've not tested this. 2. git-http-nginx-location-configuration takes an optional Nginx-style URI pattern argument that, if passed, replaces the URI generated from git-http-configuration. -- Take it easy, Richard Sent Making my computer weirder one commit at a time.