summaryrefslogtreecommitdiff
path: root/web/nginx.conf
blob: 4477a8d08b236ac17fe94f3d9bc41d417c1d6b7e (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
user root;
worker_processes 1;
events { worker_connections 256; }
http {
  include /etc/nginx/mime.types;
  default_type application/octet-stream;
  sendfile on;
  server {
    listen 80 default_server;
    server_name _;

    # статика cgit (css/иконки)
    location /cgit-static/ {
      alias /usr/share/cgit/;
      access_log off;
    }

    # git smart-HTTP: clone/push по /<repo>.git/...
    location ~ ^/(?<gitrepo>[a-zA-Z0-9._/-]+\.git)(?<gitrest>/.*)?$ {
      client_max_body_size 0;
      include /etc/nginx/fastcgi_params;
      fastcgi_param SCRIPT_FILENAME  /usr/lib/git-core/git-http-backend;
      fastcgi_param GIT_HTTP_EXPORT_ALL "";
      fastcgi_param GIT_PROJECT_ROOT /repos;
      fastcgi_param PATH_INFO        /$gitrepo$gitrest;
      fastcgi_pass unix:/run/fcgiwrap.sock;
    }

    # cgit — браузинг всего остального
    location / {
      include /etc/nginx/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       $http_host;
      fastcgi_pass unix:/run/fcgiwrap.sock;
    }
  }
}