nginx/templates/vhosts/php.j2
2024-03-27 10:45:26 +01:00

64 lines
2 KiB
Django/Jinja

{% include 'partials/map.j2' %}
{% include 'partials/upstream.j2' %}
server {
{% include 'partials/header.j2' %}
root {{ item.root|default('/var/www/html') }};
index {{ item.index|default('index.html index.htm')}};
access_log /var/log/nginx/{{ item.server_name[0] }}.access.log combined buffer=20m flush=5m;
error_log /var/log/nginx/{{ item.server_name[0] }}.error.log warn;
{% include 'partials/ssl.j2' %}
{% include 'partials/errors.j2' %}
{% if item.extra_parameters is defined %}
{{ item.extra_parameters|indent(4) }}
{% endif %}
{% if item.cache is defined and item.cache == true %}
open_file_cache max=2000 inactive=5m;
open_file_cache_valid 2m;
open_file_cache_min_uses 2;
open_file_cache_errors on;
{% endif %}
{% include 'partials/letsencrypt-webroot.j2' %}
{% include 'partials/robots.txt.j2' %}
{% if item.location is defined %}
{{ item.location|indent(4) }}
{% endif %}
location ~ {{ item.phplocationregex | default("\.php$")}} {
{% if item.phpsocket is defined %}
fastcgi_pass unix:{{ item.phpsocket }}
{% else %}
fastcgi_pass unix:/run/php/{{ item.server_name[0] }}.sock;
{% endif %}
{% if item.extraphplocation is defined %}
{% for param in item.extraphplocation %}
{{ param }}
{% endfor %}
{% else %}
{% if item.nophptryfile is defined %}
{% else %}
try_files $uri =404;
{% endif %}
fastcgi_index index.php;
{% if item.php_document_root is defined %}
fastcgi_param SCRIPT_FILENAME {{ item.php_document_root }}$fastcgi_script_name;
{% else %}
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
{% endif %}
{%if item.fastcgi_param is defined %}
{%for param in item.fastcgi_param %}
fastcgi_param {{ param.name }} {{ param.value }};
{% endfor %}
{% endif %}
include fastcgi_params;
{% endif %}
}
}