map $http_host $blogid { default -999; # Must Read - http://rtcamp.com/tutorials/nginx-maps-wordpress-multisite-static-files-handling/ # foo.example.com 3; # bar.example.com 4; include /var/www/example.com/htdocs/wp-content/plugins/nginx-helper/map.conf; } server { # @DM - Uncomment following line for domain mapping or # You will need to add every mapped-domain to server_name list #listen 80 default_server; server_name example.com *.example.com; # @DM - Uncomment following line for domain mapping #server_name_in_redirect off; access_log /var/log/nginx/example.com.access.log; error_log /var/log/nginx/example.com.error.log; root /var/www/example.com/htdocs; index index.php index.htm index.html; location / { try_files $uri $uri/ /index.php?$args; } location ~ \.php$ { include fastcgi_params; try_files $uri /index.php; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/var/run/php5-fpm.sock; # @DM - Uncomment following line for wordpress-plugins that uses value of _SERVER["SERVER_NAME"] #fastcgi_param SERVER_NAME $http_host; } # WPMU Files location ~ ^/files/(.*)$ { try_files /wp-content/blogs.dir/$blogid/$uri /wp-includes/ms-files.php?file=$1; expires max; access_log off; log_not_found off; } # WPMU x-sendfile To Avoid PHP readfile() location ^~ /blogs.dir { internal; alias /var/www/example.com/htdocs/wp-content/blogs.dir; expires max; access_log off; log_not_found off; } 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)$ { expires max; access_log off; log_not_found off; } location = /favicon.php { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } location ~ /\. { deny all; access_log off; log_not_found off; } }