diff --git a/roles/php_website/templates/nginx_site.j2 b/roles/php_website/templates/nginx_site.j2 index 27d4c89349f99b8d076c93137f92904e905f3093..d6ab61ed76ecba0cb7b815970ad4f3baadbff47e 100644 --- a/roles/php_website/templates/nginx_site.j2 +++ b/roles/php_website/templates/nginx_site.j2 @@ -5,10 +5,12 @@ server { index {{ index }}; server_name {{ fqdn }}; + {% if rewrites -%} # Generic URL rewrites. {% for rewrite in rewrites -%} rewrite {{ rewrite }}; - {% endfor %} + {% endfor -%} + {% endif %} {% if deny_files_regex -%} # Deny access to user-specified files. @@ -16,7 +18,7 @@ server { location ~ {{ regex }} { deny all; } - {% endfor %} + {% endfor -%} {% endif %} # Interpret PHP files via FastCGI. @@ -27,17 +29,17 @@ server { # Serve the files. location ~ /(.+) { - try_files $uri $uri/{% if php_rewrite_urls %}@php_rewrite{% endif %}; + try_files $uri $uri/{% if php_rewrite_urls %} @php_rewrite{% endif %}; } {% if php_rewrite_urls -%} # Apply URL rewrites. location @php_rewrite { - {% for rewrite in php_rewrite_urls -%} - rewrite {{ rewrite }}; - {% endfor %} + {% for rewrite in php_rewrite_urls %} + rewrite {{ rewrite }}; + {% endfor -%} } - {% endif %} + {% endif -%} access_log /var/log/nginx/{{ fqdn }}-access.log; error_log /var/log/nginx/{{ fqdn }}-error.log;