Correction : nginx : if is evil.
[lhc/ateliers.git] / etc / nginx / site.d / cyclo-letabli / site.conf
1 server_name
2 letabli.cyclocoop.org
3 letabli.org;
4 root /home/www/data/cyclo-letabli/www;
5
6 rewrite /wp-admin$ $scheme://$host$uri/ permanent;
7 # Add trailing slash to */wp-admin requests.
8 location = /wp-admin/ {
9 return 301 /wp-admin/index.php?$args;
10 }
11 location / {
12 index index.html index.htm index.php;
13 try_files $uri $uri/ /index.php?$args;
14 }
15 location ~* ^.+\.(css|gif|html|ico|jpeg|js|jpg|png|txt|xml)$ {
16 access_log off;
17 expires 30d;
18 log_not_found off;
19 }
20 location ~ /\. {
21 access_log off;
22 deny all;
23 log_not_found off;
24 }
25 location ~ \.php(|/.+)$ {
26 include /etc/nginx/conf.d/fastcgi.conf;
27 set $no_cache "0";
28 if ($request_method !~ ^(GET|HEAD)$) {
29 # NOTE: if non GET/HEAD, don't cache and mark user as uncacheable for 1 second via cookie.
30 set $no_cache "1";
31 }
32 if ($no_cache = "1") {
33 # NOTE: drop no cache cookie if need be (for some reason, add_header fails if included in prior if-block).
34 add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
35 add_header X-Microcachable "0";
36 }
37 if ($http_cookie ~* "_mcnc") {
38 # NOTE: bypass cache if no-cache cookie is set
39 set $no_cache "1";
40 }
41 fastcgi_cache_bypass $no_cache;
42 fastcgi_cache_use_stale updating;
43 fastcgi_cache_valid 200 10s;
44 fastcgi_cache_valid 404 10m;
45 fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
46 fastcgi_index index.php;
47 fastcgi_no_cache $no_cache;
48 fastcgi_param REDIRECT_STATUS 200;
49 # NOTE: PHP only, required if PHP was built with --enable-force-cgi-redirect
50 fastcgi_pass_header Cookie;
51 fastcgi_pass_header Set-Cookie;
52 fastcgi_split_path_info ^(.+\.php)(/.+)$;
53 try_files $fastcgi_script_name =404;
54 # Check for path info security issue
55
56
57 fastcgi_pass unix:/run/php5/fpm/letabli;
58 }
59
60 # vim: ft=sh