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