Migrate to jinja block ok

This commit is contained in:
Emilien Mantel
2015-07-30 13:02:21 +02:00
parent 084a6f283b
commit ec94521c5b
8 changed files with 152 additions and 34 deletions

View File

@@ -0,0 +1,70 @@
{% set __listen = item.listen | default(['80']) %}
{% set __listen_ssl = item.listen_ssl | default(['443']) %}
#
# {{ ansible_managed }}
#
#
# HTTP
#
server {
{% for port in __listen %}
listen {{ port }};
{% endfor %}
server_name {{ item.name | join(' ') }};
{% if item.root is defined %}
root {{ item.root }};
{% else %}
root {{ nginx_root }}/{{ item.name[0] }}/public;
{% endif %}
{% block template_index %}
index {{ item.index | default('index.html index.htm') }};
{% endblock %}
{% block template_try_files %}
try_files $uri $uri/ =404;
{% endblock %}
{% block template_custom_location %}
{% endblock %}
location ~ /\.ht {
deny all;
}
location ~* \.(txt|js|css|png|jpg|jpeg|gif|ico|svg)$ {
expires 30d;
log_not_found off;
}
{% if item.use_access_log is defined and item.use_access_log %}
access_log {{ nginx_log_dir }}/{{ item.name }}_access.log combined;
{% else %}
access_log off;
{% endif %}
{% if item.use_error_log is defined and item.use_error_log %}
error_log {{ nginx_log_dir }}/{{ item.name }}_error.log {{ nginx_error_log_level }};
{% else %}
error_log off;
{% endif %}
}
# HTTPS
#server {
#}
{% if item.redirect_from is defined and item.redirect_from is iterable %}
#
# Redirect from
#
server {
{% for port in __listen %}
listen {{ port }};
{% endfor %}
server_name {{ item.redirect_from | join(' ') }};
return 301 $scheme://{{ item.name[0] }}$request_uri;
}
{% endif %}
# vim:filetype=nginx

View File

@@ -0,0 +1,28 @@
{% extends "_base.j2" %}
{% block template_index %}
index {{ item.index | default('index.html index.htm index.php') }};
{% endblock %}
{% block template_try_files %}
try_files $uri $uri/ index.php;
{% endblock %}
{% block template_custom_location %}
location ~ \.php$ {
fastcgi_pass php;
fastcgi_index index.php;
{# TODO: fastcgi_intercept_errors {{ item.php.intercept_errors | default('on') }}; #}
fastcgi_intercept_errors on;
{% if nginx_version.stdout | version_compare('1.6.1', 'lt') %}
include fastcgi_params;
{% else %}
include fastcgi.conf;
{% endif %}
# TODO...
# Newrelic custom header: https://docs.newrelic.com/docs/apm/other-features/request-queueing/request-queue-server-configuration-examples
#fastcgi_param HTTP_X_REQUEST_START "t=${msec}";
# Newrelic custom PHP appname: https://docs.newrelic.com/docs/agents/php-agent/configuration/php-directory-ini-settings#perdir-nginx
#fastcgi_param PHP_VALUE "newrelic.appname=${host}";
}
{% endblock %}