roles/nginx: Tweaks for vhosts with WordPress

My WordPress blogs have a /wordpress subdirectory in the document
root, but I don't serve from the /wordpress URI.

Technically, all we need is the tweaks to the try_files:
    - `?args` passes query strings to php5-fpm
    - removing 404 from the vhost's try_files so we don't return 404
    when the requested file doesn't exist (obviously not all request
    URI's in WordPress are actual files on the disk)

Signed-off-by: Alan Orth <alan.orth@gmail.com>
This commit is contained in:
Alan Orth 2014-09-07 22:51:34 +03:00
parent df65172952
commit 2156f8b07d
Signed by: alanorth
GPG Key ID: 0FB860CC9C45B1B9
2 changed files with 14 additions and 3 deletions

View File

@ -1,6 +1,7 @@
{% set domain_name = item.nginx_domain_name %}
{% set domain_aliases = item.nginx_domain_aliases | default("") %}
{% set use_https = item.use_https | default("no") %}
{% set has_wordpress = item.has_wordpress | default("no") %}
{% if use_https == "yes" %}
# http -> https vhost
@ -34,9 +35,9 @@ server {
{% include 'https.j2' %}
{% endif %}
location / {
try_files $uri $uri/ =404;
}
{% if has_wordpress == "yes" %}
{% include 'wordpress.j2' %}
{% endif %}
error_page 500 502 503 504 /50x.html;
location = /50x.html {

View File

@ -0,0 +1,10 @@
# try for WordPress index.php in /
# fall back to index.php + args (passed to php5-fpm later)
location / {
try_files $uri $uri/ /index.php?$args;
}
# Add trailing slash to */wp-admin requests.
rewrite /wp-admin$ $scheme://$host$uri/ permanent;