Skip to content

Instantly share code, notes, and snippets.

@davidpfahler
Created June 20, 2014 16:32
Show Gist options
  • Save davidpfahler/61d5c700cf7b5e6b7e76 to your computer and use it in GitHub Desktop.
Save davidpfahler/61d5c700cf7b5e6b7e76 to your computer and use it in GitHub Desktop.
# appbusinesspodcast.com.conf
server {
listen 80;
index index.php index.htm index.html;
server_name 162.243.79.83 appbusinesspodcast.com *.appbusinesspodcast.com;
root /var/www/appbusinesspodcast.com;
access_log /usr/local/nginx/logs/appbusinesspodcast.com.access.log;
error_log /usr/local/nginx/logs/appbusinesspodcast.com.error.log;
# the next two location blocks are to ensure gzip encoding is turned off
# for the serving of already gzipped w3tc page cache
# normally gzip static would handle this but W3TC names them with _gzip
location ~ /wp-content/cache/page_enhanced.*html$ {
expires max;
charset utf-8;
add_header Vary "Accept-Encoding, Cookie";
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location ~ /wp-content/cache/page_enhanced.*gzip$ {
expires max;
gzip off;
types {}
charset utf-8;
default_type text/html;
add_header Vary "Accept-Encoding, Cookie";
add_header Content-Encoding gzip;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
location / {
if (-f $request_filename) {
break;
}
set $w3tc_rewrite 1;
if ($request_method = POST) { set $w3tc_rewrite 0; }
if ($query_string != "") { set $w3tc_rewrite 0; }
set $w3tc_rewrite2 1;
if ($request_uri !~ \/$) { set $w3tc_rewrite2 0; }
if ($request_uri ~* "(sitemap(_index)?\.xml(\.gz)?|[a-z0-9_\-]+-sitemap([0-9]+)?\.xml(\.gz)?)") { set $w3tc_rewrite2 1; }
if ($w3tc_rewrite2 != 1) { set $w3tc_rewrite 0; }
if ($http_cookie ~* "(comment_author|wp\-postpass|wordpress_\[a\-f0\-9\]\+|wordpress_logged_in)") { set $w3tc_rewrite 0; }
if ($http_user_agent ~* "(W3\ Total\ Cache)") { set $w3tc_rewrite 0; }
set $w3tc_ua "";
set $w3tc_ref "";
set $w3tc_ssl "";
set $w3tc_enc "";
if ($http_accept_encoding ~ gzip) { set $w3tc_enc _gzip; }
set $w3tc_ext "";
if (-f "$document_root/wp-content/cache/page_enhanced/$host/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl.html$w3tc_enc") {
set $w3tc_ext .html;
}
if ($w3tc_ext = "") { set $w3tc_rewrite 0; }
if ($w3tc_rewrite = 1) {
rewrite ^ "/wp-content/cache/page_enhanced/$host/$request_uri/_index$w3tc_ua$w3tc_ref$w3tc_ssl$w3tc_ext$w3tc_enc" last;
}
if (!-e $request_filename) {
rewrite ^ /index.php last;
}
}
# location /search { limit_req zone=kbeezieone burst=3 nodelay; rewrite ^ /index.php; }
fastcgi_intercept_errors off;
location ~* \.(ico|css|js|gif|jpe?g|png)$ {
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
include php.conf;
# You may want to remove the robots line from drop to use a virtual robots.txt
# or create a drop_wp.conf tailored to the needs of the wordpress configuration
include drop.conf;
}
# php.conf
client_max_body_size 12M;
location ~ \.php {
# for security reasons the next line is highly encouraged
try_files $uri =404;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
# if the next line in yours still contains $document_root
# consider switching to $request_filename provides
# better support for directives such as alias
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# If using a unix socket...
# fastcgi_pass unix:/tmp/php5-fpm.sock;
# If using a TCP connection...
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
# drop.conf
location = /robots.txt { access_log off; log_not_found off; }
location = /favicon.ico { access_log off; log_not_found off; }
location ~ /\. { access_log off; log_not_found off; deny all; }
location ~ ~$ { access_log off; log_not_found off; deny all; }
@mxlje
Copy link

mxlje commented Jun 20, 2014

hast du hier mal durchgeschaut? http://wiki.nginx.org/WordPress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment