summaryrefslogtreecommitdiff
path: root/site.conf
blob: e4cda3cf4bae698d59da8362be79102293c463dd (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
server {
  listen      80;
  listen [::]:80;

  server_name _;

  location ~ ^/git_write/ {
    rewrite ^/git_write/(.*) /\$1 break;

    auth_basic            "Git";
    auth_basic_user_file  $GIT_HOME.htpasswd;

    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME   $GIT_HTTP_BACKEND;
    fastcgi_param GIT_PROJECT_ROOT  $GIT_HOME;
    fastcgi_param PATH_INFO         \$uri;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }

  location ~ ^/git_read/ {
    rewrite ^/git_read/(.*) /\$1 break;

    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME   $GIT_HTTP_BACKEND;
    fastcgi_param GIT_PROJECT_ROOT  $GIT_HOME;
    fastcgi_param PATH_INFO         \$uri;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }

  location ~ \\.git {
    if (\$arg_service = git-receive-pack) {
      rewrite /(.*) /git_write/\$1 last;
    }
    if (\$uri ~ ^/.*/git-receive-pack\$) {
      rewrite /(.*) /git_write/\$1 last;
    }
    if (\$arg_service = git-upload-pack) {
      rewrite /(.*) /git_read/\$1 last;
    }
    if (\$uri ~ ^/.*/git-upload-pack\$) {
      rewrite /(.*) /git_read/\$1 last;
    }
  }

  location ^~ /git/ {
    rewrite ^/git/(.*) /\$1 break;
    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $CGIT_CGI;
    fastcgi_param PATH_INFO       \$uri;
    fastcgi_param QUERY_STRING    \$args;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }

  location ~* \\.(txt|asc|htm|css|svg|jpg|png|gif|ico|woff|woff2|js|wasm|mp3)\$ {
    rewrite ^/(.*) /static/plain/\$1 break;
    include       fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $CGIT_CGI;
    fastcgi_param PATH_INFO       \$uri;
    fastcgi_param QUERY_STRING    \$args;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }

  location / {
    include       /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME /srv/main.cgi;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
  }
}