Skip to content

Instantly share code, notes, and snippets.

@omega8cc
Created January 25, 2012 18:43
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save omega8cc/1677835 to your computer and use it in GitHub Desktop.
Save omega8cc/1677835 to your computer and use it in GitHub Desktop.
#######################################################
### nginx.conf site wp vhost include start
#######################################################
###
### deny crawlers without 403 response
###
if ($http_user_agent ~* (HTTrack|HTMLParser|libwww|wget) ) {
return 444;
}
###
### deny access to .htaccess
###
location ~ \.htaccess$ {
deny all;
}
###
### catch all unspecified requests
###
location / {
try_files $uri $uri/ @wordpress;
}
###
### send all not cached requests to wordpress with clean URLs support
###
location @wordpress {
rewrite . /index.php last;
}
###
### send all non-static requests to php-fpm
###
location ~ \.php$ {
try_files $uri @wordpress; ### check for existence of php file first
fastcgi_pass 127.0.0.1:9000; ### php-fpm listening on port 9000
}
###
### serve & no-log static files & images directly, without all standard drupal rewrites, php-fpm etc.
###
location ~* ^.+\.(jpg|jpeg|gif|png|ico|swf|pdf|doc|xls|tiff|tif|txt|shtml|cgi|bat|pl|dll|asp|exe|class|css|js)$ {
access_log off;
expires 30d;
try_files $uri =404;
}
###
### serve & log bigger media/static/archive files directly, without all standard drupal rewrites, php-fpm etc.
###
location ~* ^.+\.(avi|mpg|mpeg|mov|wmv|mp3|mp4|m4a|flv|wav|midi|zip|gz|rar)$ {
expires 30d;
try_files $uri =404;
}
###
### make feeds compatible with boost caching and set correct mime type - nginx 0.7.27 or newer required with try_files support
###
location ~* \.xml$ {
charset utf-8;
types { }
default_type application/rss+xml;
try_files $uri @wordpress;
}
#######################################################
### nginx.conf site wp vhost include end
#######################################################
@ar-jan
Copy link

ar-jan commented Sep 15, 2014

Good idea to reflect the php-fpm on unix socket change here also.

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