blob: 36753d3e9fb33b25ab5598587329baf28cda1bcf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
{% if cgit_tls_cert.stat.exists | default(false) %}
server {
server_name {{ cgit_domain }};
# Security headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
root /usr/share/cgit;
try_files $uri @cgit;
# Serve static cgit assets directly
location ~* ^/cgit-css/(.*)$ {
alias /usr/share/cgit/$1;
expires 30d;
}
# Block git-Receive-pack over HTTP (pushing is strictly via SSH as git@)
location ~ ^/.*/git-receive-pack$ {
return 403;
}
location @cgit {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_param HTTP_HOST $server_name;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
listen 443 ssl; # managed by Certbot / Ansible
listen [::]:443 ssl; # managed by Certbot / Ansible
ssl_certificate /etc/letsencrypt/live/{{ cgit_domain }}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{{ cgit_domain }}/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}
server {
if ($host = {{ cgit_domain }}) {
return 301 https://$host$request_uri;
}
listen 80;
listen [::]:80;
server_name {{ cgit_domain }};
return 404;
}
{% else %}
server {
listen 80;
listen [::]:80;
server_name {{ cgit_domain }};
root /usr/share/cgit;
try_files $uri @cgit;
# Serve static cgit assets directly
location ~* ^/cgit-css/(.*)$ {
alias /usr/share/cgit/$1;
expires 30d;
}
# Block git-receive-pack over HTTP (pushing is strictly via SSH as git@)
location ~ ^/.*/git-receive-pack$ {
return 403;
}
location @cgit {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
fastcgi_param PATH_INFO $uri;
fastcgi_param QUERY_STRING $args;
fastcgi_param HTTP_HOST $server_name;
fastcgi_pass unix:/run/fcgiwrap.socket;
}
}
{% endif %}
|