nginx/templates/etc/nginx/sites-available/wpfarm.j2

74 lines
2.2 KiB
Django/Jinja

{% extends "core.j2" %}
{% block root %}
root {{ nginx_www_dir }}{{ item.root }};
index {{ item.index }};
try_files {{ item.override_try_files | default('$uri $uri/ /index.php') }};
{% endblock %}
{% block location %}
location ~ \.php$ {
{% if item.upstream_params is defined and item.upstream_params is iterable %}
{% for param in item.upstream_params %}
{{ param }}
{% endfor %}
{% endif %}
include fastcgi_params;
}
{% endblock %}
{% block app_specific %}
# BEGIN W3TC Browser Cache
rewrite ^/wp-content/cache/minify.*/w3tc_rewrite_test$ /wp-content/plugins/w3-total-cache/pub/minify.php?w3tc_rewrite_test=1 last;
rewrite ^/wp-content/cache/minify/(.+/[X]+\.css)$ /wp-content/plugins/w3-total-cache/pub/minify.php?test_file=$1 last;
rewrite ^/wp-content/cache/minify/(.+\.(css|js))$ /wp-content/plugins/w3-total-cache/pub/minify.php?file=$1 last;
# END W3TC Minify core
# WordPress multisite subdirectory rules.
# Designed to be included in any server {} block.
# This order might seem weird - this is attempted to match last if rules below fail.
# http://wiki.nginx.org/HttpCoreModule
#location / {
# try_files $uri $uri/ /index.php?$args;
#}
location ~ ^(/[^/]+/)?files/(.+) {
try_files /wp-content/blogs.dir/$blogid/files/[ /wp-includes/ms-files.php?file=[ ;
access_log off;
log_not_found off;
expires max;
}
# Rewrite multisite '.../wp-.*' and '.../*.php'.
if (!-e $request_filename) {
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) ( last;
rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ ( last;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny access to any files with a .php extension in the uploads directory
# Works in sub-directory installs and also in multisite network
# Keep logging the requests to parse later (or to pass to firewall utilities such as fail2ban)
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
{% endblock %}
{% block extra_upstreams %}
map $http_host $blogid {
default 0;
}
{% endblock %}