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:
parent
df65172952
commit
2156f8b07d
@ -1,6 +1,7 @@
|
|||||||
{% set domain_name = item.nginx_domain_name %}
|
{% set domain_name = item.nginx_domain_name %}
|
||||||
{% set domain_aliases = item.nginx_domain_aliases | default("") %}
|
{% set domain_aliases = item.nginx_domain_aliases | default("") %}
|
||||||
{% set use_https = item.use_https | default("no") %}
|
{% set use_https = item.use_https | default("no") %}
|
||||||
|
{% set has_wordpress = item.has_wordpress | default("no") %}
|
||||||
|
|
||||||
{% if use_https == "yes" %}
|
{% if use_https == "yes" %}
|
||||||
# http -> https vhost
|
# http -> https vhost
|
||||||
@ -34,9 +35,9 @@ server {
|
|||||||
{% include 'https.j2' %}
|
{% include 'https.j2' %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
location / {
|
{% if has_wordpress == "yes" %}
|
||||||
try_files $uri $uri/ =404;
|
{% include 'wordpress.j2' %}
|
||||||
}
|
{% endif %}
|
||||||
|
|
||||||
error_page 500 502 503 504 /50x.html;
|
error_page 500 502 503 504 /50x.html;
|
||||||
location = /50x.html {
|
location = /50x.html {
|
||||||
|
10
roles/nginx/templates/wordpress.j2
Normal file
10
roles/nginx/templates/wordpress.j2
Normal 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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user