diff options
Diffstat (limited to 'roles/gitolite/http/templates/nginx-vhost.conf.j2')
-rw-r--r-- | roles/gitolite/http/templates/nginx-vhost.conf.j2 | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/roles/gitolite/http/templates/nginx-vhost.conf.j2 b/roles/gitolite/http/templates/nginx-vhost.conf.j2 new file mode 100644 index 00000000..add7a719 --- /dev/null +++ b/roles/gitolite/http/templates/nginx-vhost.conf.j2 @@ -0,0 +1,72 @@ + server { + listen 80; + listen [::]:80; + server_name {{ gitolite_instances[gitolite_instance].http.hostnames | join(' ') }}; + + access_log /var/log/nginx/git-{{ gitolite_instance }}_access.log; + error_log /var/log/nginx/git-{{ gitolite_instance }}_error.log; + + include snippets/acmetool.conf; + + location / { + return 301 https://$host$request_uri; + } +} + +server { + listen 443 ssl http2; + listen [::]:443 ssl http2; + server_name {{ gitolite_instances[gitolite_instance].http.hostnames | join(' ') }}; + + access_log /var/log/nginx/git-{{ gitolite_instance }}_access.log; + error_log /var/log/nginx/git-{{ gitolite_instance }}_error.log; + + include snippets/acmetool.conf; + include snippets/tls.conf; + ssl_certificate /var/lib/acme/live/{{ gitolite_instances[gitolite_instance].http.hostnames[0] }}/fullchain; + ssl_certificate_key /var/lib/acme/live/{{ gitolite_instances[gitolite_instance].http.hostnames[0] }}/privkey; + include snippets/hsts.conf; + + location = / { + return 303 /cgit/; + } + + location /cgit-css/ { + alias /usr/share/cgit/; + } +{% if 'logo' in gitolite_instances[gitolite_instance].http %} + + location = /logo.png { + alias /usr/local/share/cgit/{{ gitolite_instance }}.png; + } +{% endif %} + + location /cgit/ { + include fastcgi_params; + fastcgi_split_path_info ^(/cgit)(.*)$; + + fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param QUERY_STRING $args; + fastcgi_param HTTP_HOST $server_name; + fastcgi_param CGIT_CONFIG {{ gitolite_base_path }}/{{ gitolite_instance }}/cgitrc; + + fastcgi_pass unix:/run/fcgiwrap/gitolite-{{ gitolite_instance }}.sock; + } +{% if 'enable_git_backend' in gitolite_instances[gitolite_instance].http and gitolite_instances[gitolite_instance].http.enable_git_backend %} + + location ~ ^.*/git-receive-pack$ { + return 403; + } + + location ~ ^.*/(HEAD|info/refs|objects/(info/.*|[0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx))|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_PROJECT_ROOT {{ gitolite_base_path }}/{{ gitolite_instance }}/repositories; + + fastcgi_pass unix:/run/fcgiwrap/gitolite-{{ gitolite_instance }}.sock; + } +{% endif %} +} |