Skip to content

Instantly share code, notes, and snippets.

@BrianGilbert
Forked from omega8cc/gist:1677835
Last active April 25, 2022 11:55
Show Gist options
  • Save BrianGilbert/6227135 to your computer and use it in GitHub Desktop.
Save BrianGilbert/6227135 to your computer and use it in GitHub Desktop.
Create it as: /var/aegir/config/includes/nginx_wp_include.conf and add it in your custom vhost eg. https://gist.github.com/BrianGilbert/6227181
#######################################################
### 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:9090; ### 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
#######################################################
@yazzou
Copy link

yazzou commented Sep 17, 2014

Did not work after updating my baracuda to the following version :
BOA-2.3.1
Is there a fix to make hosted wordpress site be live again ?
Thanks

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