diff --git a/roles/wsgi_website/templates/nginx_site.j2 b/roles/wsgi_website/templates/nginx_site.j2 new file mode 100644 index 0000000000000000000000000000000000000000..dbc13bc3e954b107d751bf3f6bc1d248a1123480 --- /dev/null +++ b/roles/wsgi_website/templates/nginx_site.j2 @@ -0,0 +1,35 @@ +server { + listen 80; + + root {{ home }}/htdocs/; + + server_name {{ fqdn }}; + + # Site rewrites. + {% for rewrite in rewrites -%} + rewrite {{ rewrite }}; + {% endfor %} + + # Static locations + {% for location in static_locations -%} + location {{ location }} { + try_files $uri $uri/ =404; + } + {% endfor %} + + # 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; +}