Advertisement
Guest User

Untitled

a guest
Nov 15th, 2013
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.62 KB | None | 0 0
  1. fastcgi_cache_path /etc/nginx/cache levels=1:2 keys_zone=MYAPP:100m inactive=60m;
  2. fastcgi_cache_key "$scheme$request_method$host$request_uri";
  3. add_header X-Cache $upstream_cache_status;
  4.  
  5. server {
  6.         listen   80;
  7.  
  8.  
  9.         root /var/www/site1/wordpress;
  10.         index index.php index.html index.htm;
  11.  
  12.         server_name example.com www.example.com;
  13.  
  14.         location / {
  15.                 try_files $uri $uri/ /index.php?q=$uri&$args;
  16.         }
  17.  
  18.         error_page 404 /404.html;
  19.  
  20.         error_page 500 502 503 504 /50x.html;
  21.         location = /50x.html {
  22.               root /usr/share/nginx/www;
  23.         }
  24.  
  25.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  26.        location ~ \.php$ {
  27.                 try_files $uri =404;
  28.                 #fastcgi_pass 127.0.0.1:9000;
  29.                # With php5-fpm:
  30.                fastcgi_pass unix:/var/run/php5-fpm.sock;
  31.                 fastcgi_index index.php;
  32.                 include fastcgi_params;
  33.         fastcgi_cache MYAPP;
  34.         fastcgi_cache_valid 200 60m;
  35.                 fastcgi_cache_bypass $no_cache;
  36.         fastcgi_no_cache $no_cache;
  37.         }
  38.  
  39.         #Cache everything by default
  40.     set $no_cache 0;
  41.  
  42.     #Don't cache POST requests
  43.     if ($request_method = POST)
  44.     {
  45.         set $no_cache 1;
  46.     }
  47.  
  48.     #Don't cache if the URL contains a query string
  49.     if ($query_string != "")
  50.     {
  51.         set $no_cache 1;
  52.     }
  53.  
  54.     #Don't cache the following URLs
  55.     if ($request_url ~* "/(administrator/|login.php)")
  56.     {
  57.         set $no_cache 1;
  58.     }
  59.  
  60.     #Don't cache if there is a cookie called PHPSESSID
  61.     if ($http_cookie = "PHPSESSID")
  62.     {
  63.         set $no_cache 1;
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement