Files @ 9fa438ee34c0
Branch filter:

Location: majic-ansible-roles/roles/wsgi_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 {
    listen 80;

    root {{ home }}/htdocs/;

    server_name {{ fqdn }};

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

    {% if static_locations -%}
    # Static locations
    {% for location in static_locations -%}
    location {{ location }} {
        try_files $uri $uri/ =404;
    }
    {% endfor -%}
    {% endif %}

    # Pass remaining requests to the WSGI server.
    location / {
        try_files $uri @proxy_to_app;
    }

    location @proxy_to_app {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;

        proxy_pass http://unix:/run/wsgi/{{ fqdn }}.sock;
    }

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