infra/roles/pretalx/templates/nginx.conf

82 lines
2.6 KiB
Nginx Configuration File

upstream pretalx_{{ pretalx_instance_identifier }}_server {
server unix:/run/gunicorn/pretalx_{{ pretalx_instance_identifier }} fail_timeout=0;
}
proxy_cache_path /tmp/nginx-pretalx-{{ pretalx_instance_identifier }} levels=1:2 keys_zone=pretalx_static_{{ pretalx_instance_identifier }}:10m inactive=60m max_size=250m;
{% if pretalx_nginx_force_https and not pretalx_nginx_http_only %}
server {
listen 80;
listen [::]:80;
server_name {{ pretalx_domain }}{% if pretalx_alternate_domains %} {{ pretalx_alternate_domains }}{% endif %};
return 301 https://$host$request_uri;
}
{% endif %}
{% if pretalx_nginx_http_only %}
server {
listen 80;
listen [::]:80;
server_name {{ pretalx_domain }}{% if pretalx_alternate_domains %} {{ pretalx_alternate_domains }}{% endif %};
{% else %}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name {{ pretalx_domain }}{% if pretalx_alternate_domains %} {{ pretalx_alternate_domains }}{% endif %};
# ssl on;
# ssl_certificate {{ pretalx_cert_root }}/{{ pretalx_domain }}/fullchain.pem;
# ssl_certificate_key {{ pretalx_cert_root }}/{{ pretalx_domain }}/privkey.pem;
# proxy_set_header X-Forwarded-Proto https;
include snippets/letsencrypt-{{ pretalx_domain }}.conf;
{% endif %}
access_log /var/log/nginx/pretalx_{{ pretalx_instance_identifier }}.access.log;
error_log /var/log/nginx/pretalx_{{ pretalx_instance_identifier }}.error.log;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# If you decide to turn gzip on, turn it off explicitly for ~ (*.)/schedule/export/(*.)
# or your export pages won't show their (working, existing) etags.
# You'd think that gzip_proxied no_etag; would work. It doesn't.
gzip off;
location /static/ {
access_log off;
alias {{ pretalx_staticfiles_directory }}/;
}
location /static/CACHE/ {
gzip on;
expires 30d;
add_header Cache-Control public;
add_header Pragma public;
add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
proxy_cache pretalx_static_{{ pretalx_instance_identifier }};
proxy_ignore_headers Cache-Control;
proxy_cache_valid any 60m;
add_header X-Proxy-Cache $upstream_cache_status;
alias {{ pretalx_staticfiles_directory }}/CACHE/;
}
location /media/ {
gzip on;
alias {{ pretalx_media_dir }}/;
add_header Content-Disposition 'attachment';
}
location / {
proxy_pass http://pretalx_{{ pretalx_instance_identifier }}_server;
}
client_max_body_size 32M;
}