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