unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Sent <richard@freakingpenguin.com>
To: 68610@debbugs.gnu.org
Subject: bug#68610: URI path in git-http-nginx-location-configuration doesn't accept / properly
Date: Sat, 20 Jan 2024 12:18:47 -0500	[thread overview]
Message-ID: <87zfwzapoo.fsf@freakingpenguin.com> (raw)

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.




                 reply	other threads:[~2024-01-20 17:20 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87zfwzapoo.fsf@freakingpenguin.com \
    --to=richard@freakingpenguin.com \
    --cc=68610@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).