Created
February 16, 2014 13:43
-
-
Save centminmod/9034414 to your computer and use it in GitHub Desktop.
Wordpress Multi Site Nginx configuration template for CentminMod.com Nginx - based on Sam Smith's configuration at https://plus.google.com/b/104831941868856035845/106999818358907937014/posts/YN2sCBjxg2A
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
server_name domain1.com www.domain1.com domain2.com www.domain2.com; | |
# ngx_pagespeed & ngx_pagespeed handler | |
include /usr/local/nginx/conf/pagespeed.conf; | |
include /usr/local/nginx/conf/pagespeedhandler.conf; | |
include /usr/local/nginx/conf/pagespeedstatslog.conf; | |
access_log /home/nginx/domains/domain1.com/log/access.log combined buffer=32k; | |
error_log /home/nginx/domains/domain1.com/log/error.log; | |
root /home/nginx/domains/domain1.com/public; | |
location / { | |
if (-f $request_filename/index.html){ | |
rewrite (.*) $1/index.html break; | |
} | |
if (-f $request_filename/index.php){ | |
rewrite (.*) $1/index.php; | |
} | |
if (!-f $request_filename){ | |
rewrite (.*) /index.php; | |
} | |
} | |
# Pass uploaded files to wp-includes/ms-files.php. | |
rewrite /files/$ /index.php last; | |
if ($uri !~ wp-content/plugins) { | |
rewrite /files/(.+)$ /wp-includes/ms-files.php?file=$1 last; | |
} | |
# Rewrite multisite '.../wp-.' and '.../.php'. | |
if (!-e $request_filename) { | |
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last; | |
rewrite ^/[_0-9a-zA-Z-]+.(/wp-admin/.\.php)$ $1 last; | |
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last; | |
} | |
include /usr/local/nginx/conf/wpsecure.conf; | |
include /usr/local/nginx/conf/wpnocache.conf; | |
include /usr/local/nginx/conf/staticfiles.conf; | |
include /usr/local/nginx/conf/php.conf; | |
include /usr/local/nginx/conf/drop.conf; | |
} | |
------------------------------------------------------------------------ | |
/usr/local/nginx/conf/wpsecure.conf contents | |
# Deny access to any files with a .php extension in the uploads directory | |
# Works in sub-directory installs and also in multisite network | |
location ~* /(?:uploads|files)/.*\.php$ { | |
deny all; | |
} | |
# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS! | |
location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ | |
{ | |
return 444; | |
} | |
#nocgi | |
location ~* \.(pl|cgi|py|sh|lua)\$ { | |
return 444; | |
} | |
#disallow | |
location ~* (roundcube|webdav|smtp|http\:|soap|w00tw00t) { | |
return 444; | |
} | |
location ~ /(\.|wp-config.php|readme.html|license.txt) { deny all; } | |
------------------------------------------------------------------------ | |
/usr/local/nginx/conf/wpnocache.conf contents | |
# Add trailing slash to */wp-admin requests. | |
rewrite /wp-admin$ $scheme://$host$uri/ permanent; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Help me with:
nginx configuration
charset utf-8;$http_host ~* "^www.(.+)$ "){
error_page 404 /index.php;
location /CMS/ {
if (!-e $request_filename){
rewrite ^/CMS/site-([a-zA-Z0-9])$ /CMS/index.php/?__cms_subsite=$1 break;
}
if (!-e $request_filename){
rewrite ^/CMS/(.)$ /CMS/index.php/$1 break;
}
if (
rewrite ^/CMS/(.)$ http://%1$request_uri redirect;
}
if ($script_filename ~ "-d"){
return 403;
}
if ($script_filename ~ "-f"){
return 403;
}
}
location /CMS/site {
rewrite ^/CMS/site-([a-zA-Z0-9])/(.*)$ /CMS/index.php/$2?__cms_subsite=$1 break;
}
Please!