diff --git a/templates/etc/nginx/sites-available/COMMON.j2 b/templates/etc/nginx/sites-available/COMMON.j2 index ab07286..ffed30d 100644 --- a/templates/etc/nginx/sites-available/COMMON.j2 +++ b/templates/etc/nginx/sites-available/COMMON.j2 @@ -14,7 +14,11 @@ server_name {{ server_name | join(' ') }}; {% endif %} +{% if item.root is defined %} + root {{ item.root }}; +{% else %} root {{ nginx_root }}/{{ item.name }}/public; +{% endif %} {% if item.use_access_log is defined and item.use_access_log %} access_log {{ nginx_log_dir }}/{{ item.name }}_access.log combined; diff --git a/templates/etc/nginx/upstream/php.conf.j2 b/templates/etc/nginx/upstream/php.conf.j2 index e8034d2..2f086f9 100644 --- a/templates/etc/nginx/upstream/php.conf.j2 +++ b/templates/etc/nginx/upstream/php.conf.j2 @@ -1,22 +1,15 @@ # # {{ ansible_managed }} # -{% if nginx_php_method == 'tcp' %} + upstream php { - {% if nginx_cluster_php_method is defined %} - {{ nginx_cluster_php_method }}; + {% for item in nginx_php_sockets %} + {% if item.unix_socket is defined %} + server unix:{{ item.unix_socket }} weight={{ item.weight | default('1') }}; + {% else %} + server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('1') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }}; {% endif %} - {% for item in nginx_php_tcp_sockets %} - server {{ item.host }}:{{ item.port }} weight={{ item.weight | default('100') }} max_fails={{ item.max_fails | default('5') }} fail_timeout={{ item.fail_timeout | default('10s') }}; {% endfor %} } -{% elif nginx_php_method == 'unix' %} -upstream php { - {% for item in nginx_php_unix_sockets %} - server unix:{{ item }}; - {% endfor %} -} -{% else %} -{% endif %} # vim:filetype=nginx diff --git a/tests/test.yml b/tests/test.yml index 51c468c..6533a4c 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -8,6 +8,8 @@ - lineinfile: dest=/etc/hosts line="127.0.2.2 {{ nginx_vhosts|map(attribute='name')| join(' ') }}" vars: nginx_php: true + nginx_php_unix_sockets: + - unix_socket: "/var/run/php5-fpm.sock" nginx_vhosts: - name: 'test.local' aliases: