Private
Public Access
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d91da6fc6 | ||
|
|
c316f411f8 | ||
|
|
e1907ff587 | ||
|
|
b0d62c91f8 |
No files matched your search
@@ -3,6 +3,14 @@ from .base import env
|
|||||||
|
|
||||||
DEBUG = False
|
DEBUG = False
|
||||||
|
|
||||||
|
# Health checks (scripts/upgrade.sh, an external uptime monitor, ...) hit
|
||||||
|
# gunicorn directly over loopback, bypassing the reverse proxy entirely —
|
||||||
|
# that request's Host header is "127.0.0.1:<port>", not the public domain
|
||||||
|
# in ALLOWED_HOSTS, so without this Django 400s it. Harmless to always
|
||||||
|
# allow: gunicorn's bind address is never reachable from outside this host
|
||||||
|
# in the first place (see docs/install.md's "Reverse proxy" section).
|
||||||
|
ALLOWED_HOSTS = [*ALLOWED_HOSTS, "localhost", "127.0.0.1", "::1"] # noqa: F405
|
||||||
|
|
||||||
# A reverse proxy (nginx, Caddy, Traefik, Nginx Proxy Manager on another
|
# A reverse proxy (nginx, Caddy, Traefik, Nginx Proxy Manager on another
|
||||||
# host, ...) is required in front of gunicorn in every deployment — see
|
# host, ...) is required in front of gunicorn in every deployment — see
|
||||||
# docs/install.md — and it's always the one terminating TLS. This tells
|
# docs/install.md — and it's always the one terminating TLS. This tells
|
||||||
@@ -10,6 +18,11 @@ DEBUG = False
|
|||||||
# sets, and the redirect/cookie/HSTS settings below assume it's set.
|
# sets, and the redirect/cookie/HSTS settings below assume it's set.
|
||||||
SECURE_SSL_REDIRECT = env.bool("SECURE_SSL_REDIRECT", default=True)
|
SECURE_SSL_REDIRECT = env.bool("SECURE_SSL_REDIRECT", default=True)
|
||||||
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https")
|
||||||
|
# /health/ is also exempted from the HTTPS redirect above: hit directly
|
||||||
|
# over loopback (see ALLOWED_HOSTS above) it has no X-Forwarded-Proto
|
||||||
|
# header to prove it's "secure", and there's no TLS listener on gunicorn's
|
||||||
|
# own port to redirect to anyway.
|
||||||
|
SECURE_REDIRECT_EXEMPT = [r"^health/$"]
|
||||||
|
|
||||||
# WhiteNoise serves /static/ directly from gunicorn instead of relying on
|
# WhiteNoise serves /static/ directly from gunicorn instead of relying on
|
||||||
# the reverse proxy to alias the staticfiles directory on disk — the proxy
|
# the reverse proxy to alias the staticfiles directory on disk — the proxy
|
||||||
|
|||||||
+39
-3
@@ -63,9 +63,45 @@ if ! "$PYTHON_BIN" -c 'import ensurepip' >/dev/null 2>&1; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v redis-cli >/dev/null 2>&1; then
|
# Celery (and therefore all feed fetching) is entirely dependent on Redis
|
||||||
echo "Warning: 'redis-cli' not found on PATH. Install it before going live" \
|
# being reachable — it fails silently from the installer's point of view
|
||||||
"(see docs/install.md's prerequisites section: apt install redis-server)." >&2
|
# (the worker/beat processes just retry forever in the background), so this
|
||||||
|
# has to be a hard failure here, not a warning that's easy to miss while
|
||||||
|
# every later step "succeeds" at installing an app that can never fetch a
|
||||||
|
# single feed. Check the actual REDIS_URL that will end up in .env (an
|
||||||
|
# explicit EVECTION_REDIS_URL override, if set — the default local Redis
|
||||||
|
# otherwise), not just whether some redis-cli happens to be on PATH.
|
||||||
|
REDIS_URL_TO_CHECK="${EVECTION_REDIS_URL:-redis://localhost:6379/0}"
|
||||||
|
check_redis() {
|
||||||
|
"$PYTHON_BIN" -c "
|
||||||
|
import sys, socket, urllib.parse
|
||||||
|
u = urllib.parse.urlparse('$REDIS_URL_TO_CHECK')
|
||||||
|
try:
|
||||||
|
with socket.create_connection((u.hostname or 'localhost', u.port or 6379), timeout=3):
|
||||||
|
pass
|
||||||
|
except OSError as e:
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
"
|
||||||
|
}
|
||||||
|
REDIS_HOST="$("$PYTHON_BIN" -c "import urllib.parse; print(urllib.parse.urlparse('$REDIS_URL_TO_CHECK').hostname or 'localhost')")"
|
||||||
|
if ! check_redis; then
|
||||||
|
if [[ "$REDIS_HOST" =~ ^(localhost|127\.0\.0\.1|::1)$ ]] && command -v apt-get >/dev/null 2>&1; then
|
||||||
|
echo "==> Redis isn't reachable at $REDIS_URL_TO_CHECK — installing redis-server"
|
||||||
|
apt-get install -y redis-server
|
||||||
|
systemctl enable --now redis-server
|
||||||
|
if ! check_redis; then
|
||||||
|
echo "Redis still isn't reachable after installing redis-server —" \
|
||||||
|
"check: systemctl status redis-server" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Redis isn't reachable at $REDIS_URL_TO_CHECK. Evection's background" \
|
||||||
|
"feed-fetching depends on it entirely, so this has to be fixed before" \
|
||||||
|
"continuing — either start/install Redis there, or set" \
|
||||||
|
"EVECTION_REDIS_URL to point at wherever it actually runs." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --- 2. System user -----------------------------------------------------
|
# --- 2. System user -----------------------------------------------------
|
||||||
|
|||||||
+10
-1
@@ -112,7 +112,16 @@ HEALTH_PORT="${HEALTH_BIND##*:}"
|
|||||||
if [ "$HEALTH_HOST" = "0.0.0.0" ]; then
|
if [ "$HEALTH_HOST" = "0.0.0.0" ]; then
|
||||||
HEALTH_HOST="127.0.0.1"
|
HEALTH_HOST="127.0.0.1"
|
||||||
fi
|
fi
|
||||||
if curl -sf "http://$HEALTH_HOST:$HEALTH_PORT/health/" >/dev/null; then
|
# Use the venv's own Python rather than curl — curl isn't guaranteed to be
|
||||||
|
# installed on a minimal host, but the venv obviously already is.
|
||||||
|
if "$VENV_DIR/bin/python" -c "
|
||||||
|
import sys, urllib.request
|
||||||
|
try:
|
||||||
|
urllib.request.urlopen('http://$HEALTH_HOST:$HEALTH_PORT/health/', timeout=5)
|
||||||
|
except Exception as e:
|
||||||
|
print(e, file=sys.stderr)
|
||||||
|
sys.exit(1)
|
||||||
|
"; then
|
||||||
echo "Health check OK"
|
echo "Health check OK"
|
||||||
else
|
else
|
||||||
echo "Health check FAILED — check: journalctl -u evection-gunicorn -n 50" >&2
|
echo "Health check FAILED — check: journalctl -u evection-gunicorn -n 50" >&2
|
||||||
|
|||||||
+7
-1
@@ -300,12 +300,18 @@ form p {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-tag-link {
|
.sidebar-tag-link {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 0.15rem 0.4rem;
|
||||||
|
margin: -0.15rem -0.4rem;
|
||||||
|
border-radius: 0.375rem;
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-tag-link.active {
|
.sidebar-tag-link.active {
|
||||||
color: var(--accent);
|
background: var(--bg-row-selected);
|
||||||
|
color: var(--text);
|
||||||
|
font-weight: 600;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar-item-list {
|
.sidebar-item-list {
|
||||||
|
|||||||
Reference in new issue
Block a user