Files @ 9fa438ee34c0
Branch filter:

Location: majic-ansible-roles/roles/php_website/templates/nginx_site.j2

branko
MAR-5: Added another example to role reference for running PHP websites. Allow duplicates of roles php_website and wsgi_website. Use parameter in handler for restarting WSGI website (to have them website-specific). Updated test site to force handler execution in order to avoid being in undefined state.
server {
    # Base settings.
    listen 80;
    root {{ home }}/htdocs/;
    index {{ index }};
    server_name {{ fqdn }};

    {% if rewrites -%}
    # Generic URL rewrites.
    {% for rewrite in rewrites -%}
    rewrite {{ rewrite }};
    {% endfor -%}
    {% endif %}

    {% if deny_files_regex -%}
    # Deny access to user-specified files.
    {% for regex in deny_files_regex -%}
    location ~ {{ regex }} {
        deny all;
    }
    {% endfor -%}
    {% endif %}

    # Interpret PHP files via FastCGI.
    location ~ {{ php_file_regex }} {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php5-fpm/{{ fqdn }}.sock;
    }

    # Serve the files.
    location ~ /(.+) {
	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 -%}
    }
    {% endif -%}

    access_log /var/log/nginx/{{ fqdn }}-access.log;
    error_log /var/log/nginx/{{ fqdn }}-error.log;
}