Advertisement
Guest User

Untitled

a guest
Feb 6th, 2014
745
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.86 KB | None | 0 0
  1. server {
  2.         listen   80;
  3.         root /usr/share/nginx/www;
  4.         index index.php;
  5.         server_name website.com www.website.com;
  6.   autoindex off;
  7.   include conf.sites/wordpress-both.conf;
  8.   access_log   /var/log/nginx/website.access.log;
  9.   error_log    /var/log/nginx/website.error.log error;
  10.  
  11.   set $cache_uri $request_uri;
  12.  
  13.   # POST requests and urls with a query string should always go to PHP
  14.  
  15.   if ($request_method = POST) {
  16.     set $cache_uri 'null cache';
  17.   }
  18.   if ($query_string != "") {
  19.     set $cache_uri 'null cache';
  20.   }
  21.  
  22.   # Don't cache uris containing the following segments
  23.  if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitem$
  24.    set $cache_uri 'null cache';
  25.  }
  26.  
  27.  # Don't use the cache for logged in users or recent commenters
  28.  if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
  29.    set $cache_uri 'null cache';
  30.  }
  31.  
  32.  # Use cached or actual file if they exists, otherwise pass request to WordPress
  33.  location / {
  34.    try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
  35.    # auth_basic           "closed site";
  36.    # auth_basic_user_file .htpasswd;
  37.  }
  38. # Erase this block if the phpmyadmin security configuration below works
  39. #        location /phpmyadmin {
  40. #                try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
  41. #                auth_basic           "closed site";
  42. #                auth_basic_user_file htpasswd;
  43. #        }
  44.  
  45.  location ~* /phpmyadmin/.*\.php$ {
  46.    # try_files $uri = 404;
  47.    fastcgi_split_path_info ^(.+.php)(.*)$;
  48.    fastcgi_index index.php;
  49.    fastcgi_pass unix:/var/run/php5-fpm.sock;
  50.    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  51.    include fastcgi_params;
  52.    fastcgi_intercept_errors on;
  53.    fastcgi_ignore_client_abort off;
  54.    fastcgi_connect_timeout 60;
  55.    fastcgi_send_timeout 180;
  56.    fastcgi_read_timeout 180;
  57.    fastcgi_buffer_size 128k;
  58.    fastcgi_buffers 4 256k;
  59.    fastcgi_busy_buffers_size 256k;
  60.    fastcgi_temp_file_write_size 256k;
  61.    auth_basic "Password Protected Folder";
  62.    auth_basic_user_file /etc/nginx/.htpasswd;
  63. }
  64.  
  65.  location = /favicon.ico { log_not_found off; access_log off; }
  66.  location = /robots.txt  { log_not_found off; access_log off; }
  67.  
  68.        #location / {
  69.                # This is cool because no php is touched for static content.
  70.                # include the "?$args" part so non-default permalinks doesn't break when using query string
  71.        #        try_files $uri $uri/ /index.php?$args;
  72.        #}
  73.  
  74.        # error_page 404 /404.html;
  75.  
  76.        error_page 500 502 503 504 /50x.html;
  77.        location = /50x.html {
  78.              root /usr/share/nginx/www;
  79.        }
  80.  
  81.        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  82.        location ~ ^/.*\.php {
  83.          #fastcgi_pass 127.0.0.1:9000;
  84.                # With php5-fpm:
  85.    #try_files $uri /index.php;
  86.    try_files $uri =404;
  87.                fastcgi_pass unix:/var/run/php5-fpm.sock;
  88.                fastcgi_index index.php;
  89.                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  90.                fastcgi_intercept_errors on;
  91.    include fastcgi_params;
  92.        }
  93.  
  94.    #location /nginx_status {
  95.        # Turn on stats
  96.          #stub_status on;
  97.          #access_log off;
  98.        # only allow access from 77.103.27.165 #
  99.          #allow 89.177.49.138;
  100.          #deny all;
  101.  #}
  102.  
  103.  # Cache static files for as long as possible
  104.  location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
  105.    expires max; log_not_found off; access_log off;
  106.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement