src.nth.io/

summaryrefslogtreecommitdiff
path: root/git/web/templates/cgit.nginx.conf.j2
blob: 324dd0c8979642fa9f4d1e497a83c071cb9e7e31 (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
server {
    listen 80;
    listen [::]:80;
    server_name {{nginx_server_name}};
    return 301 https://{{nginx_server_name}}$request_uri;
}

server {
    listen 443 ssl http2;
    server_name {{nginx_server_name}};

    ssl_certificate {{nginx_ssl_cert}};
    ssl_certificate_key {{nginx_ssl_privkey}};
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

    ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
    ssl_stapling on;
    ssl_stapling_verify on;

    add_header X-Frame-Options "SAMEORIGIN" always;
    add_header X-Content-Type-Options "nosniff" always;
    add_header X-XSS-Protection "1; mode=block" always;
    add_header Referrer-Policy "strict-origin-when-cross-origin" always;

    root /usr/share/cgit;

    # Redirect old Mercurial-style paths to cgit equivalents
    rewrite ^/([^/]+)/file/tip/(.*)$ /$1/tree/$2 permanent;
    rewrite ^/([^/]+)/file/tip$      /$1/tree    permanent;
    rewrite ^/([^/]+)/file$          /$1/tree    permanent;

    try_files $uri @cgit;

    location @cgit {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi;
        fastcgi_param PATH_INFO $uri;
        fastcgi_param QUERY_STRING $query_string;
        fastcgi_param HTTP_HOST $server_name;
        fastcgi_pass unix:/run/fcgiwrap.socket;
    }
}