From e9aa3cc3f4e1905d306e90ce5c468ab81062fe7b Mon Sep 17 00:00:00 2001 From: Ariel Costas Date: Sat, 16 Jul 2022 17:24:09 +0200 Subject: Add guide on supporting clone via HTTPS --- content/cgit.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'content') diff --git a/content/cgit.md b/content/cgit.md index 70104a9..a7be427 100644 --- a/content/cgit.md +++ b/content/cgit.md @@ -129,6 +129,38 @@ chmod +x hooks/post-receive Next time you push to that repository, the idle time should reset and show the correct value. +### Allowing clone via HTTPS + +If you want others to be able to clone your git repository, you might +need to enable the `git://` daemon or give public SSH access, both of +which have their cons. You can set up your NGINX server to call a git +subprogram that allows cloning anonymously via HTTP(S). + +To do this, add the following lines to your nginx server, above the +`location @cgit` line we added before: + +```nginx +location ~ /.+/(info/refs|git-upload-pack) { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; + fastcgi_param PATH_INFO $uri; + fastcgi_param GIT_HTTP_EXPORT_ALL 1; + fastcgi_param GIT_PROJECT_ROOT /srv/git; + fastcgi_param HOME /srv/git; + fastcgi_pass unix:/run/fcgiwrap.socket; +} +``` + +Note: `GIT_PROJECT_ROOT` and `HOME` must point to the location where +your repositories are stored. + +You can also add the `clone-prefix` setting to cgit so the clone URL +is shown for each repository: + +```txt +clone-prefix=https://git.example.org +``` + ## Contribution - Ariel Costas -- [website](https://costas.dev), -- cgit v1.2.3 From 0159e33caf9f07174ea94ecbc9aaa4d8d7cd776f Mon Sep 17 00:00:00 2001 From: Ariel Costas Date: Sat, 16 Jul 2022 17:24:34 +0200 Subject: Delete obsolete donation link --- content/cgit.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'content') diff --git a/content/cgit.md b/content/cgit.md index a7be427..12d0c2f 100644 --- a/content/cgit.md +++ b/content/cgit.md @@ -163,5 +163,4 @@ clone-prefix=https://git.example.org ## Contribution -- Ariel Costas -- [website](https://costas.dev), - [donations](https://costas.dev/donations/) +- Ariel Costas -- [website](https://costas.dev) -- cgit v1.2.3 From 7ca77d1d8953e3ac6fe8283ed32cdb6cac0706e2 Mon Sep 17 00:00:00 2001 From: Ariel Costas Date: Sat, 16 Jul 2022 17:41:44 +0200 Subject: Include it as part of NGINX conf Instead of adding several new paragraphs, just keep it simple and say it's doing it as part of the base guide. --- content/cgit.md | 47 ++++++++++++++--------------------------------- 1 file changed, 14 insertions(+), 33 deletions(-) (limited to 'content') diff --git a/content/cgit.md b/content/cgit.md index 12d0c2f..63bcf80 100644 --- a/content/cgit.md +++ b/content/cgit.md @@ -48,6 +48,16 @@ server { root /usr/share/cgit ; try_files $uri @cgit ; + location ~ /.+/(info/refs|git-upload-pack) { + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; + fastcgi_param PATH_INFO $uri; + fastcgi_param GIT_HTTP_EXPORT_ALL 1; + fastcgi_param GIT_PROJECT_ROOT /srv/git; + fastcgi_param HOME /srv/git; + fastcgi_pass unix:/run/fcgiwrap.socket; + } + location @cgit { include fastcgi_params; fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; @@ -58,7 +68,9 @@ server { } ``` -Then get NGINX to reload your configuration. +Then get NGINX to reload your configuration. This configuration also enables +cloning via HTTPS, so make sure to point the `fastcgi_param GIT_PROJECT_ROOT` +to the directory where you store your repositories. ## Configuring cgit @@ -70,6 +82,7 @@ configure Cgit to our liking, by editing `/etc/cgitrc`. css=/cgit.css logo=/cgit.svg virtual-root=/ +clone-prefix=https://git.example.org # Title and description shown on top of each page root-title=Chad's git server @@ -129,38 +142,6 @@ chmod +x hooks/post-receive Next time you push to that repository, the idle time should reset and show the correct value. -### Allowing clone via HTTPS - -If you want others to be able to clone your git repository, you might -need to enable the `git://` daemon or give public SSH access, both of -which have their cons. You can set up your NGINX server to call a git -subprogram that allows cloning anonymously via HTTP(S). - -To do this, add the following lines to your nginx server, above the -`location @cgit` line we added before: - -```nginx -location ~ /.+/(info/refs|git-upload-pack) { - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend; - fastcgi_param PATH_INFO $uri; - fastcgi_param GIT_HTTP_EXPORT_ALL 1; - fastcgi_param GIT_PROJECT_ROOT /srv/git; - fastcgi_param HOME /srv/git; - fastcgi_pass unix:/run/fcgiwrap.socket; -} -``` - -Note: `GIT_PROJECT_ROOT` and `HOME` must point to the location where -your repositories are stored. - -You can also add the `clone-prefix` setting to cgit so the clone URL -is shown for each repository: - -```txt -clone-prefix=https://git.example.org -``` - ## Contribution - Ariel Costas -- [website](https://costas.dev) -- cgit v1.2.3