Make the reverse proxy a required, pluggable part of every deployment

gunicorn previously only ever bound to a Unix socket, which assumes the
reverse proxy is nginx running on this same host — it can't be reached by
a proxy on a different machine at all (e.g. Nginx Proxy Manager on its own
box), which is this project's actual deployment target. Switch gunicorn to
listening on a plain TCP address instead, controlled by a new
EVECTION_GUNICORN_BIND setting in .env.

install.sh now asks whether the proxy is local or remote and picks a
sensible bind default either way (127.0.0.1:8000 vs 0.0.0.0:8000, with a
reminder to firewall the port in the remote case), and no longer tries to
automate nginx/certbot itself — docs/install.md's new "Reverse proxy"
section covers both shapes instead, since which proxy and where it runs is
the operator's choice, not something this script should assume or set up.
upgrade.sh's health check now curls the TCP bind instead of the old socket
path.

Also add WhiteNoise so gunicorn serves /static/ itself: the old approach
(nginx aliasing the staticfiles directory on disk) silently breaks the
moment the proxy isn't on this host and can't see this filesystem.
nginx.conf.example's own /static/ alias becomes an optional same-host perf
optimization rather than a requirement.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
ksmithandClaude Sonnet 5 committed 2026-10-31 09:01:46 -06:00
1 parent 62702e13e3
commit 21c33e8188
7 files changed
+157 -91

No files matched your search

+15 -4
View File
@@ -1,6 +1,12 @@
# Reverse proxy for Evection. Copy to /etc/nginx/sites-available/evection,
# adjust server_name and the certificate paths (certbot will fill those in
# for you if you use `certbot --nginx`), then symlink into sites-enabled.
# 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;
@@ -24,6 +30,11 @@ server {
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;
@@ -36,7 +47,7 @@ server {
# else below, so no special-casing is needed here.
location / {
proxy_pass http://unix:/run/evection/gunicorn.sock;
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;