Private
Public Access
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:
1 parent
62702e13e3
commit
21c33e8188
7 files changed
+157
-91
No files matched your search
+15
-2
@@ -26,7 +26,6 @@ APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
EVECTION_HOME="$(dirname "$APP_DIR")"
|
||||
VENV_DIR="$EVECTION_HOME/venv"
|
||||
EVECTION_USER="${EVECTION_USER:-evection}"
|
||||
SOCKET="/run/evection/gunicorn.sock"
|
||||
|
||||
# $APP_DIR is owned by $EVECTION_USER, but the git steps below run as
|
||||
# root — without this, git refuses to touch a repo it doesn't own
|
||||
@@ -99,7 +98,21 @@ fi
|
||||
|
||||
echo "==> Verifying"
|
||||
sleep 2
|
||||
if curl -sf --unix-socket "$SOCKET" http://localhost/health/ >/dev/null; then
|
||||
# gunicorn always listens on a plain TCP address (EVECTION_GUNICORN_BIND in
|
||||
# .env, set by scripts/install.sh) rather than a Unix socket, since the
|
||||
# reverse proxy in front of it may be on a different host entirely — see
|
||||
# docs/install.md. 0.0.0.0 isn't a valid address to connect *to*, so check
|
||||
# against localhost in that case; this health check only needs to prove
|
||||
# gunicorn itself is answering on this host, not reach it the way the
|
||||
# proxy does.
|
||||
HEALTH_BIND="$(grep -m1 '^EVECTION_GUNICORN_BIND=' "$APP_DIR/.env" | cut -d= -f2-)"
|
||||
HEALTH_BIND="${HEALTH_BIND:-127.0.0.1:8000}"
|
||||
HEALTH_HOST="${HEALTH_BIND%:*}"
|
||||
HEALTH_PORT="${HEALTH_BIND##*:}"
|
||||
if [ "$HEALTH_HOST" = "0.0.0.0" ]; then
|
||||
HEALTH_HOST="127.0.0.1"
|
||||
fi
|
||||
if curl -sf "http://$HEALTH_HOST:$HEALTH_PORT/health/" >/dev/null; then
|
||||
echo "Health check OK"
|
||||
else
|
||||
echo "Health check FAILED — check: journalctl -u evection-gunicorn -n 50" >&2
|
||||
|
||||
Reference in new issue
Block a user