Ajout : vm_hosted : lhc-remorque .
[lhc/ateliers.git] / etc / nginx / site.d / gitweb / site.conf
diff --git a/etc/nginx/site.d/gitweb/site.conf b/etc/nginx/site.d/gitweb/site.conf
new file mode 100644 (file)
index 0000000..f15b046
--- /dev/null
@@ -0,0 +1,71 @@
+server_name git.heureux-cyclage.org;
+
+client_body_buffer_size 8k;
+client_max_body_size 10m;
+location / {
+       index index.html;
+       root /usr/share/gitweb;
+ }
+location ~* ^.+.(css|gif|html|ico|jpeg|js|jpg|png|txt|xml)$ {
+       access_log off;
+       expires 30d;
+       log_not_found off;
+ }
+location ~ /\. {
+       access_log off;
+       deny all;
+       log_not_found off;
+ }
+location ~ ^.*\.git/objects/([0-9a-f]+/[0-9a-f]+|pack/pack-[0-9a-f]+.(pack|idx)) {
+ # NOTE: static repo files for cloning over HTTP
+       root /home/git/pub;
+ }
+location ~ ^.*\.git/(HEAD|info/refs|objects/info/.*|git-(upload|receive)-pack)$ {
+ # NOTE: requests that need to go to git-http-backend
+       root /home/git/pub;
+       include /etc/nginx/conf.d/fastcgi.conf;
+       fastcgi_param GIT_HTTP_EXPORT_ALL "";
+       fastcgi_param GIT_PROJECT_ROOT /home/git/pub;
+       fastcgi_param PATH_INFO $uri;
+       fastcgi_param REMOTE_USER $remote_user;
+       fastcgi_param SCRIPT_FILENAME /usr/lib/git-core/git-http-backend;
+ }
+location @gitweb {
+       include /etc/nginx/conf.d/fastcgi.conf;
+       set $no_cache "0";
+       if ($request_method !~ ^(GET|HEAD)$) {
+        # NOTE: if non GET/HEAD, don't cache and mark user as uncacheable for 1 second via cookie.
+               set $no_cache "1";
+        }
+       if ($no_cache = "1") {
+        # NOTE: drop no cache cookie if need be (for some reason, add_header fails if included in prior if-block).
+               add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
+               add_header X-Microcachable "0";
+        }
+       if ($http_cookie ~* "_mcnc") {
+        # NOTE: bypass cache if no-cache cookie is set.
+               set $no_cache "1";
+        }
+       fastcgi_cache_bypass $no_cache;
+       fastcgi_cache_use_stale updating;
+       fastcgi_cache_valid 200 10s;
+       fastcgi_cache_valid 404 30m;
+       fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
+       fastcgi_max_temp_file_size 2M;
+       fastcgi_no_cache $no_cache;
+       fastcgi_param GITWEB_CONFIG /etc/gitweb/gitweb.conf;
+       fastcgi_param PATH_INFO $uri;
+       fastcgi_param REDIRECT_STATUS 200;
+               # NOTE: PHP only, required if PHP was built with --enable-force-cgi-redirect
+       fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
+       
+       fastcgi_pass_header Cookie;
+       fastcgi_pass_header Set-Cookie;
+       fastcgi_split_path_info ^(.+\.cgi)(/.+)$;
+       
+       fastcgi_pass unix:/run/spawn-fcgi/gitweb;
+ }
+try_files $uri @gitweb;
+ # NOTE: send anything else to gitweb if it's not a real file
+
+# vim: ft=sh