diff --git a/roles/nginx/templates/nginx.conf.j2 b/roles/nginx/templates/nginx.conf.j2 index 6b60169863..49f5b7f929 100644 --- a/roles/nginx/templates/nginx.conf.j2 +++ b/roles/nginx/templates/nginx.conf.j2 @@ -50,7 +50,22 @@ pid /run/nginx.pid; {% endblock %} http { - {% block http_begin %}{% endblock %} + {% block http_begin %} + map $upstream_cache_status $header_x_cache_enabled { + default true; + BYPASS ""; + } + + map $server_addr:$remote_addr $is_loopback_request { + "~^([^:]+):\1$" 1; + default 0; + } + + map $is_loopback_request:$header_x_cache_enabled $loopback_header_x_cache_enabled { + default ""; + 1:true true; + } + {% endblock %} {% block server_tokens -%} # Hide nginx version information. diff --git a/roles/wordpress-setup/templates/wordpress-site.conf.j2 b/roles/wordpress-setup/templates/wordpress-site.conf.j2 index 95b406439a..72b63fc0a3 100644 --- a/roles/wordpress-setup/templates/wordpress-site.conf.j2 +++ b/roles/wordpress-setup/templates/wordpress-site.conf.j2 @@ -21,6 +21,9 @@ server { index index.php index.htm index.html; add_header Fastcgi-Cache $upstream_cache_status; + # Additional proxy header for WordPress (notably its Site Health check) + add_header X-Cache-Enabled $loopback_header_x_cache_enabled; + # Specify a charset charset utf-8;