summaryrefslogtreecommitdiff
path: root/roles/gitolite/http/templates/nginx-vhost.conf.j2
blob: add7a719e6f6268bb2b3c41b26bb6d1b29427192 (plain) (blame)
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
 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 %}
}