diff options
| author | Joe Carstairs <me@joeac.net> | 2026-09-24 08:24:01 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-09-24 08:24:01 +0100 |
| commit | 55207ffd187fc703edfea2a40d118073678c813f (patch) | |
| tree | 1ce9f6d9f823bd255e0fb6c661ec6f2c90b8c9b6 | |
| parent | a036c3dfe1ae7af4429753d8ae232b140aef16fa (diff) | |
update git-http-backend configuration
| -rw-r--r-- | roles/git-http-backend/tasks/main.yml | 2 | ||||
| -rw-r--r-- | roles/git-http-backend/templates/git-http-backend.conf | 33 |
2 files changed, 20 insertions, 15 deletions
diff --git a/roles/git-http-backend/tasks/main.yml b/roles/git-http-backend/tasks/main.yml index 9dccf60..87b09bf 100644 --- a/roles/git-http-backend/tasks/main.yml +++ b/roles/git-http-backend/tasks/main.yml @@ -12,7 +12,7 @@ - name: Install htpasswd file ansible.builtin.copy: src: htpasswd - dest: /etc/nginx/.htpasswd + dest: /srv/git/.htpasswd owner: "{{ git_readwrite_user }}" group: "{{ git_readwrite_group }}" mode: "400" diff --git a/roles/git-http-backend/templates/git-http-backend.conf b/roles/git-http-backend/templates/git-http-backend.conf index 26e012b..01c2cb4 100644 --- a/roles/git-http-backend/templates/git-http-backend.conf +++ b/roles/git-http-backend/templates/git-http-backend.conf @@ -1,22 +1,27 @@ location ~ /(.+)/(HEAD|info/refs|objects|git-upload-pack|git-receive-pack) { if (-f /srv/git/$1/{{ git_export_ok_file }}) { - set $auth_basic "private-write repository"; + set $auth_basic "private-write repository"; } if (!-f /srv/git/$1/{{ git_export_ok_file }}) { - set $auth_basic "private repository"; + set $auth_basic "private repository"; } - if ($arg_service != git-receive-pack) { - set $auth_basic off; + if ($arg_service = git-upload-pack) { + set $auth_basic off; } - auth_basic $auth_basic; - auth_basic_user_file .htpasswd; + auth_basic $auth_basic; - include fastcgi_params; - fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; - fastcgi_param PATH_INFO $uri; - fastcgi_param GIT_PROJECT_ROOT /srv/git; - fastcgi_param GIT_HTTP_EXPORT_ALL 1; - fastcgi_param REMOTE_USER $remote_user; - fastcgi_param HOME /srv/git; - fastcgi_pass unix:{{ fcgiwrap_socket }}; + set $auth_basic_user_file /srv/git/.htpasswd; + if (-f /srv/git/$1/.htpasswd) { + set $auth_basic_user_file /srv/git/$1/.htpasswd; + } + auth_basic_user_file $auth_basic_user_file; + + include fastcgi_params; + fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend; + fastcgi_param PATH_INFO $uri; + fastcgi_param GIT_PROJECT_ROOT /srv/git; + fastcgi_param GIT_HTTP_EXPORT_ALL 1; + fastcgi_param REMOTE_USER $remote_user; + fastcgi_param HOME /srv/git; + fastcgi_pass unix:{{ fcgiwrap_socket }}; } |
