summaryrefslogtreecommitdiff
path: root/roles/gitserver/files/git.conf
blob: f4e880d3a5dc345412d3be50a4f7962ff2e2ba0b (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
# Source: https://gist.github.com/kierdwyn/3745400e6a184f621b92

location ~ /.+/(info/refs|git-upload-pack|git-receive-pack) {
    # Disable authentication by default.
    set $auth off;

    # Require authentication for push.
    if ($request ~ git-receive-pack) {
        set $auth "Restricted";
    }

    auth_basic $auth;
    auth_basic_user_file /etc/nginx/auth/git/.htpasswd;

    # Set chunks to unlimited, as the body's can be huge.
    client_max_body_size 0;

    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
    fastcgi_param GIT_PROJECT_ROOT /srv/git;
    fastcgi_param PATH_INFO $uri;
    # Forward REMOTE_USER as we want to know when we are authenticated.
    fastcgi_param REMOTE_USER $remote_user;

    fastcgi_pass unix:/run/fcgiwrap.sock;
}