Skip to content

Instantly share code, notes, and snippets.

Created January 8, 2014 10:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/68caceb6c935e7120a60 to your computer and use it in GitHub Desktop.
Save anonymous/68caceb6c935e7120a60 to your computer and use it in GitHub Desktop.
sites-enabled - subdir multisite - problem with media in domain mapped blogs
map $uri $blogname{
~^(?<blogpath>/[^/]+/)files/(.*) $blogpath ;
}
map $blogname $blogid{
default -999;
include /var/www/bloggmu/public/wp-content/uploads/nginx-helper/map.conf ;
}
server {
listen 80 default_server ;
server_name site.arstaskolan.se;
server_name_in_redirect off;
access_log /var/log/nginx/acbloggmu.log;
error_log /var/log/nginx/erbloggmu.log;
root /var/www/bloggmu/public;
index index.php;
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^(/[^/]+)?(/wp-.*) $2 last;
rewrite ^(/[^/]+)?(/.*\.php) $2 last;
}
location / {
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
try_files $uri /index.php;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
#avoid php readfile()
location ^~ /blogs.dir {
internal;
alias /var/www/bloggmu/public/wp-content/blogs.dir ;
access_log off; log_not_found off; expires max;
}
location ~ ^(/[^/]+/)?files/(?<rt_file>.+) {
try_files /wp-content/blogs.dir/$blogid/files/$rt_file /wp-includes/ms-files.php?file=$rt_file ;
access_log off; log_not_found off; expires max;
}
location ~ ^(/[^/]+/)?files/(?<rt_file>.+) {
try_files /wp-content/blogs.dir/$blogid/files/$rt_file /wp-includes/ms-files.php?file=$rt_file ;
access_log off; log_not_found off; expires max;
}
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment