Skip to content

Instantly share code, notes, and snippets.

@nkmail
Forked from centminmod/gist:9034414
Last active October 25, 2017 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nkmail/e773eb06cad252029ff91957b4dd4cbe to your computer and use it in GitHub Desktop.
Save nkmail/e773eb06cad252029ff91957b4dd4cbe to your computer and use it in GitHub Desktop.
Wordpress Multi Site Nginx configuration template for CentminMod.com Nginx - based on Peter Downy community member
map $uri $blogname{
~^(?<blogpath>/[^/]+/)sites/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
include /home/nginx/domains/domain1.com/public/wp-content/uploads/nginx-helper/map.conf ;
}
server {
server_name domain1.com www.domain1.com domain2.com www.domain2.com domain3.com www.domain3.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;
# limit_conn limit_per_ip 16;
# ssi on;
access_log /home/nginx/domains/domain1.com/log/access.log combined buffer=8k;
error_log /home/nginx/domains/domain1.com/log/error.log;
#access_log /var/log/nginx/access.cache.log cache;
root /home/nginx/domains/domain1.com/public;
# Rewrites for WordPress SEO XML Sitemap
rewrite ^/sitemap_index.xml$ /index.php?sitemap=1 last;
rewrite ^/([^/]+?)-sitemap([0-9]+)?.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
}
## Admin Rewrites
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^/[^/]+(/.*.php)$ $1 last;
}
location / {
include /usr/local/nginx/conf/wpsecure.conf;
include /usr/local/nginx/conf/wpcache.conf;
## Permalinks
try_files $uri $uri/ /index.php?$args;
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;
}
}
# block common exploits, sql injections etc
include /usr/local/nginx/conf/block.conf;
# Other includes
include /usr/local/nginx/conf/staticfiles.conf;
include /usr/local/nginx/conf/phpwpcache.conf;
include /usr/local/nginx/conf/drop.conf;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment