Skip to content

Commit 617c3ba

Browse files
fix(url): fix railway urls
1 parent a02db20 commit 617c3ba

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,10 @@ For CI, prefer a scoped token over a password: see [`devpi-tokens`](https://pypi
107107
| `DEVPI_SECRETFILE` | `/data/.secret` | Persistent server secret. Required so login tokens survive a redeploy. |
108108
| `DEVPI_RESTRICT_MODIFY` | `root` | Only `root` can create users/indexes. Set to an empty string to allow any logged-in user to create their own. |
109109
| `DEVPI_THEME_DIR` | `/app/theme` | Folder passed to devpi-server's `--theme`. Ships with a built-in modern theme (system fonts, dark mode). Point it at a folder under `/data` to use your own, or set to an empty string for the stock devpi look. |
110+
| `DEVPI_OUTSIDE_URL` | *(auto-detected)* | Full public URL of the service, used by devpi-web to build absolute links. On Railway it is auto-derived from `RAILWAY_PUBLIC_DOMAIN`. Set it explicitly only if you front the service with a custom domain or another proxy. |
111+
| `DEVPI_TRUSTED_PROXY` | `*` | Passed to `devpi-server --trusted-proxy`. `*` trusts any proxy — required so `X-Forwarded-Proto` from Railway's edge is honoured and links are generated as `https://` instead of `http://`. |
112+
| `DEVPI_TRUSTED_PROXY_COUNT` | `1` | Number of proxies in front of the service. |
113+
| `DEVPI_TRUSTED_PROXY_HEADERS` | `x-forwarded-proto x-forwarded-for x-forwarded-host` | Forwarded headers devpi-server will trust. |
110114

111115
## Persistence & the `/data` volume
112116

entrypoint.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ set -euo pipefail
55
: "${DEVPI_SERVERDIR:=/data/server}"
66
: "${DEVPI_SECRETFILE:=/data/.secret}"
77
: "${DEVPI_RESTRICT_MODIFY:=root}"
8+
: "${DEVPI_TRUSTED_PROXY:=*}"
9+
: "${DEVPI_TRUSTED_PROXY_COUNT:=1}"
10+
: "${DEVPI_TRUSTED_PROXY_HEADERS:=x-forwarded-proto x-forwarded-for x-forwarded-host}"
11+
12+
# On Railway, RAILWAY_PUBLIC_DOMAIN is injected automatically for services
13+
# with a public domain. Use it to set --outside-url so devpi-web generates
14+
# correct https:// links (no mixed-content) unless the user overrode it.
15+
if [ -z "${DEVPI_OUTSIDE_URL:-}" ] && [ -n "${RAILWAY_PUBLIC_DOMAIN:-}" ]; then
16+
DEVPI_OUTSIDE_URL="https://${RAILWAY_PUBLIC_DOMAIN}"
17+
fi
818

919
INIT_SENTINEL="/data/.initialized"
1020

@@ -35,8 +45,16 @@ server_args=(
3545
--host 0.0.0.0
3646
--port "$PORT"
3747
--request-timeout 60
48+
--trusted-proxy "$DEVPI_TRUSTED_PROXY"
49+
--trusted-proxy-count "$DEVPI_TRUSTED_PROXY_COUNT"
50+
--trusted-proxy-headers "$DEVPI_TRUSTED_PROXY_HEADERS"
3851
)
3952

53+
if [ -n "${DEVPI_OUTSIDE_URL:-}" ]; then
54+
echo "[entrypoint] outside URL: $DEVPI_OUTSIDE_URL"
55+
server_args+=(--outside-url "$DEVPI_OUTSIDE_URL")
56+
fi
57+
4058
if [ -n "$DEVPI_RESTRICT_MODIFY" ]; then
4159
server_args+=(--restrict-modify "$DEVPI_RESTRICT_MODIFY")
4260
fi

0 commit comments

Comments
 (0)