Correction : vm_hosted : etc/nginx/site.d/gitweb/ .
[lhc/ateliers.git] / etc / nginx / site.d / gitweb / site.conf
1 server_name git.heureux-cyclage.org;
2
3 client_body_buffer_size 8k;
4 client_max_body_size 10m;
5 location ~* ^.+\.(css|png|js)$ {
6 root /usr/share/gitweb;
7 access_log off;
8 expires 30d;
9 log_not_found off;
10 }
11 location ~ /\. {
12 access_log off;
13 deny all;
14 log_not_found off;
15 }
16 location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx)) {
17 # NOTE: static repo files for cloning over HTTP
18 root /home/git/pub;
19 }
20 location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
21 # NOTE: requests that need to go to git-http-backend
22 root /home/git/pub;
23 include /etc/nginx/conf.d/fastcgi.conf;
24 fastcgi_param GIT_HTTP_EXPORT_ALL "";
25 fastcgi_param GIT_PROJECT_ROOT /home/git/pub;
26 fastcgi_param PATH_INFO $uri;
27 fastcgi_param REMOTE_USER $remote_user;
28 fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
29 }
30 location @gitweb {
31 root /usr/share/gitweb;
32 fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
33 include /etc/nginx/conf.d/fastcgi.conf;
34 set $no_cache "0";
35 if ($request_method !~ ^(GET|HEAD)$) {
36 # NOTE: if non GET/HEAD, don't cache and mark user as uncacheable for 1 second via cookie.
37 set $no_cache "1";
38 }
39 if ($no_cache = "1") {
40 # NOTE: drop no cache cookie if need be (for some reason, add_header fails if included in prior if-block).
41 add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
42 add_header X-Microcachable "0";
43 }
44 if ($http_cookie ~* "_mcnc") {
45 # NOTE: bypass cache if no-cache cookie is set.
46 set $no_cache "1";
47 }
48 fastcgi_cache_bypass $no_cache;
49 fastcgi_cache_use_stale updating;
50 fastcgi_cache_valid 200 10s;
51 fastcgi_cache_valid 404 30m;
52 fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
53 fastcgi_max_temp_file_size 2M;
54 fastcgi_no_cache $no_cache;
55 fastcgi_param GITWEB_CONFIG /etc/gitweb/gitweb.conf;
56 fastcgi_param PATH_INFO $uri;
57
58 fastcgi_pass_header Cookie;
59 fastcgi_pass_header Set-Cookie;
60 fastcgi_split_path_info ^(.+\.cgi)(/.+)$;
61
62 fastcgi_pass unix:/run/spawn-fcgi/gitweb;
63 }
64 try_files $uri @gitweb;
65 # NOTE: send anything else to gitweb if it's not a real file
66
67 # vim: ft=sh