Correction : vm_{hosted,remote} : chemins et noms, suite.
[lhc/ateliers.git] / etc / nginx / site.d / lhc-git / site.conf
1 server_name git.heureux-cyclage.org;
2
3 client_body_buffer_size 8k;
4 client_max_body_size 10m;
5 location / {
6 index index.html index.htm index.php;
7 root /usr/share/gitweb;
8 }
9 location ~* ^.+.(css|gif|html|ico|jpeg|js|jpg|png|txt|xml)$ {
10 access_log off;
11 expires 30d;
12 log_not_found off;
13 }
14 location ~ /\. {
15 access_log off;
16 deny all;
17 log_not_found off;
18 }
19 location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx)) {
20 # NOTE: static repo files for cloning over HTTP
21 root /home/git/pub;
22 }
23 location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
24 # NOTE: requests that need to go to git-http-backend
25 root /home/git/pub;
26 include /etc/nginx/conf.d/fastcgi.conf;
27 fastcgi_param GIT_HTTP_EXPORT_ALL "";
28 fastcgi_param GIT_PROJECT_ROOT /home/git/pub/git;
29 fastcgi_param PATH_INFO $uri;
30 fastcgi_param REMOTE_USER $remote_user;
31 fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
32 }
33 location @gitweb {
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 fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
59
60 fastcgi_pass_header Cookie;
61 fastcgi_pass_header Set-Cookie;
62 fastcgi_split_path_info ^(.+\.php)(/.+)$;
63
64 fastcgi_pass unix:/run/php5/fpm/gitweb;
65 }
66 ssl_session_timeout 5m;
67 try_files $uri @gitweb;
68 # NOTE: send anything else to gitweb if it's not a real file
69
70 # vim: ft=sh