GNU bug report logs - #68610
URI path in git-http-nginx-location-configuration doesn't accept / properly

Previous Next

Package: guix;

Reported by: Richard Sent <richard <at> freakingpenguin.com>

Date: Sat, 20 Jan 2024 17:20:02 UTC

Severity: normal

To reply to this bug, email your comments to 68610 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#68610; Package guix. (Sat, 20 Jan 2024 17:20:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Richard Sent <richard <at> freakingpenguin.com>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Sat, 20 Jan 2024 17:20:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Richard Sent <richard <at> freakingpenguin.com>
To: bug-guix <at> gnu.org
Subject: URI path in git-http-nginx-location-configuration doesn't accept /
 properly
Date: Sat, 20 Jan 2024 12:18:47 -0500
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.




This bug report was last modified 104 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.