42 lines
1.4 KiB
Django/Jinja
42 lines
1.4 KiB
Django/Jinja
server {
|
|
listen 443 ssl;
|
|
server_name {{app['nginx_host_pattern']}};
|
|
|
|
ssl_certificate {{ssl_certificate}};
|
|
ssl_certificate_key {{ssl_certificate_key}};
|
|
|
|
access_log /var/log/nginx/{{app['project_name']}}-access.log combined;
|
|
error_log /var/log/nginx/{{app['project_name']}}-error.log;
|
|
|
|
location ~ ^/static/(.+)$ {
|
|
root /;
|
|
try_files /var/lib/{{app['project_name']}}/tenants/$host/static/$1
|
|
/var/lib/{{app['project_name']}}/collectstatic/$1
|
|
=404;
|
|
add_header Access-Control-Allow-Origin *;
|
|
}
|
|
|
|
location ~ ^/media/(.+)$ {
|
|
alias /var/lib/{{app['project_name']}}/tenants/$host/media/$1;
|
|
}
|
|
|
|
location / {
|
|
proxy_pass http://localhost:{{app['server_port']}};
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header X-Forwarded-SSL on;
|
|
proxy_set_header X-Forwarded-Protocol ssl;
|
|
proxy_set_header X-Forwarded-Proto https;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
}
|
|
}
|
|
|
|
# catchall http → https
|
|
server {
|
|
listen 80;
|
|
server_name {{app['nginx_host_pattern']}};
|
|
access_log /var/log/nginx/{{app['project_name']}}-access.log combined;
|
|
error_log /var/log/nginx/{{app['project_name']}}-error.log;
|
|
return 301 https://$host$request_uri;
|
|
}
|