1ede3791df4cd33892ec848e0fc37914bad6c321
[lhc/ateliers.git] / etc / nginx / site.d / cyclo-wiki / site.conf
1 server_name
2 wiki.cyclocoop.org;
3
4 access_log /home/www/log/cyclo-wiki/nginx/access.piwik.log piwik;
5 #auth_basic "pour demander un compte: admin+wiki@cyclocoop.org";
6 #auth_basic_user_file /home/www/data/cyclo-wiki/.htpasswd;
7 client_body_buffer_size 8k;
8 client_max_body_size 10m;
9 error_page 404 /cgi/ikiwiki.cgi?do=create&page=$uri;
10
11 location ~ ^/gitweb/static/.+\.(css|png|js)$ {
12 root /usr/share/;
13 access_log off;
14 expires 30d;
15 log_not_found off;
16 }
17 location ~ ^/gitweb($|/) {
18 #auth_basic "no pasaran";
19 #auth_basic_user_file /home/www/data/cyclo-wiki/.htpasswd;
20 root /usr/share/gitweb;
21 fastcgi_param SCRIPT_FILENAME /usr/share/gitweb/gitweb.cgi;
22 include /etc/nginx/conf.d/fastcgi.conf;
23 set $no_cache "0";
24 if ($request_method !~ ^(GET|HEAD)$) {
25 # NOTE: if non GET/HEAD, don't cache and mark user as uncacheable for 1 second via cookie.
26 set $no_cache "1";
27 }
28 if ($no_cache = "1") {
29 # NOTE: drop no cache cookie if need be (for some reason, add_header fails if included in prior if-block).
30 add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
31 add_header X-Microcachable "0";
32 }
33 if ($http_cookie ~* "_mcnc") {
34 # NOTE: bypass cache if no-cache cookie is set.
35 set $no_cache "1";
36 }
37 fastcgi_cache_bypass $no_cache;
38 fastcgi_cache_use_stale updating;
39 fastcgi_cache_valid 200 10s;
40 fastcgi_cache_valid 404 30m;
41 fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
42 fastcgi_no_cache $no_cache;
43 fastcgi_param GITWEB_CONFIG /etc/gitweb/cyclo-wiki.conf;
44 fastcgi_param PATH_INFO $uri;
45
46 fastcgi_pass_header Cookie;
47 fastcgi_pass_header Set-Cookie;
48 fastcgi_split_path_info ^(.+\.cgi)(/.+)$;
49
50 fastcgi_pass unix:/run/spawn-fcgi/gitweb;
51 }
52
53 location /cgi/ikiwiki.cgi {
54 include /etc/nginx/conf.d/fastcgi.conf;
55 set $r "$https$arg_do";
56 if ($r = "create") {
57 return 301 https://$host$request_uri;
58 }
59 if ($r = "edit") {
60 return 301 https://$host$request_uri;
61 }
62 if ($r = "prefs") {
63 return 301 https://$host$request_uri;
64 }
65 fastcgi_index cgi/ikiwiki.cgi;
66 fastcgi_pass unix:/run/spawn-fcgi/cyclo-wiki;
67 }
68 location ~* ^.+\.(css|gif|ico|jpeg|js|jpg|png)$ {
69 access_log off;
70 expires 30d;
71 log_not_found off;
72 }
73 location ~* ^.+\.(html|txt|xhtml|xml)$ {
74 expires 60s;
75 }
76 location ~ /\. {
77 access_log off;
78 deny all;
79 log_not_found off;
80 }
81 location / {
82 index index.html;
83 }
84 location /3615 {
85 rewrite ^/3615(.*)$ https://3615.cyclocoop.org$1 last;
86 #return 301 https://3615.cyclocoop.org;
87 }
88
89 # vim: ft=sh