# Reverse proxy for Evection, for the case where nginx runs on the SAME host # as Evection (see docs/install.md's "Reverse proxy" section — if your proxy # is on a different host/VM instead, e.g. Nginx Proxy Manager, this file # doesn't apply to you directly, but the proxy_set_header lines below still # show what any proxy needs to forward). Copy to # /etc/nginx/sites-available/evection, adjust server_name, the certificate # paths (certbot will fill those in for you if you use `certbot --nginx`), # and the port in proxy_pass if you didn't use EVECTION_GUNICORN_BIND's # default of 127.0.0.1:8000, then symlink into sites-enabled. server { listen 80; listen [::]:80; server_name your-domain.example; # certbot --nginx adds the HTTPS server block and redirects here # automatically; until then this serves plain HTTP. location / { return 301 https://$host$request_uri; } } server { listen 443 ssl; listen [::]:443 ssl; server_name your-domain.example; ssl_certificate /etc/letsencrypt/live/your-domain.example/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/your-domain.example/privkey.pem; client_max_body_size 10M; # OPML uploads are small, but leave headroom # Optional: gunicorn already serves /static/ itself via WhiteNoise (with # its own far-future cache headers, since filenames are content-hashed), # so this block is purely a same-host perf optimization that skips # gunicorn for static assets — not required, and not an option at all # once the proxy is on a different host than $APP_DIR/staticfiles. location /static/ { alias /opt/evection/app/staticfiles/; expires 30d; add_header Cache-Control "public, immutable"; } # The service worker must be served from the domain root with the right # scope header for its Service-Worker-Allowed: / to take effect — it's # already a normal Django view (see apps.pwa), proxied like everything # else below, so no special-casing is needed here. location / { proxy_pass http://127.0.0.1:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }