Skip to content
ASP.NET Core HTTPS behind Railway: supported proxy trust or end-to-end TLS via TCP Proxy
rdesideri
OP

a month ago

We are preparing a teacher-review portal on an existing ASP.NET Core 8 service on Railway. Public HTTPS requests should consistently reach the application's HTTPS-only authentication routes, but anonymous requests intermittently receive HTTP 400 before login. The teacher feature has not been enabled for real users. We want a supported Railway-only configuration; this is an integration question, not a claim of a Railway outage or vulnerability.

Observations

On 2026-10-09 at 18:53 UTC-03:00, an anonymous GET to the teacher login returned HTTP 200 with the form disabled as expected for the current feature configuration. At 18:54, two further anonymous GETs to that same route returned HTTP 400; the health endpoint returned HTTP 200. TLS certificate validation was enabled in the client and redirects were not followed. No credentials were submitted.

The backend listens on HTTP behind Railway's TLS-terminating edge. Our forwarded-header middleware accepts protocol/client headers only from explicitly trusted peers. Earlier read-only diagnostics observed multiple last-hop peer addresses. The 400 responses are consistent with the application's Request.IsHttps guard, but we did not correlate an individual failing request with its peer and headers, so the precise cause remains a hypothesis. We have not widened proxy trust or disabled HTTPS checks.

We read the Public Networking specs, Edge Networking and TCP Proxy documentation and related Central Station discussions about proxy trust. They explain TLS termination and forwarding, but we still need guidance on the supported trust boundary for ASP.NET Core's known-proxy checks.

Questions

  1. What is the supported configuration for recognizing Railway ingress reliably across requests/redeploys while preventing a direct/private-network caller from impersonating the edge through forwarded headers? Are stable ingress identities, listener isolation or authenticated origin connections available?
  2. What guarantees apply to overwriting/sanitizing X-Forwarded-Proto and X-Real-IP, duplicate values and the number of forwarding hops?
  3. If the native ingress cannot meet that boundary, is end-to-end TLS terminated by Kestrel through Railway TCP Proxy supported for a separate HTTPS teacher portal? We understand we would manage the certificate/renewal and a custom CNAME would still require the allocated external port. Are there relevant restrictions or a Railway-only alternative that retains standard HTTPS port 443?

The AI assistant recommended contacting support because the available documentation did not settle these ingress guarantees. The owner authorized this request. We are asking for platform guidance, not for changes to the project: please do not change DNS, services, plan, access rules or data. The affected service is selected in the support form. No logs containing credentials or personal data are attached.

Prepared with Railway's support template (v1).

Solved

3 Replies

Railway
BOT

a month ago

We don't publish a stable range for the proxy addresses your container sees as its socket peer. Any address you've observed, including one in 100.64.0.0/10, can change at any time, so a fixed KnownProxies/KnownNetworks list will break intermittently. Since ASP.NET Core 8.0.17, Forwarded Headers Middleware ignores X-Forwarded-Proto from untrusted peers, which fits the intermittent 400s from your Request.IsHttps guard.

On the public HTTP edge, we overwrite X-Real-IP, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, replacing any copies the caller sent. X-Forwarded-Proto is set to https. We don't promise a single X-Forwarded-For entry or a fixed number of hops.

Requests over *.railway.internal skip the edge, so they don't get this header handling. Any service in the same project and environment can reach your port and send its own forwarding headers. Trusting forwarded headers from every peer therefore means trusting every service in that environment, and any TCP proxy you expose. Private networks are isolated between projects and environments, so keeping the portal in an environment with no untrusted services is what limits who can reach it.

TCP Proxy is raw passthrough. We don't terminate TLS or issue a certificate there, so Kestrel would handle TLS and renewal. Clients connect on the allocated external port, and no forwarding headers are added or cleaned up on that path.


Status changed to Awaiting User Response Railway • about 1 month ago


Railway

We don't publish a stable range for the proxy addresses your container sees as its socket peer. Any address you've observed, including one in `100.64.0.0/10`, can change at any time, so a fixed `KnownProxies`/`KnownNetworks` list will break intermittently. Since ASP.NET Core 8.0.17, Forwarded Headers Middleware ignores `X-Forwarded-Proto` from untrusted peers, which fits the intermittent 400s from your `Request.IsHttps` guard. On the public HTTP edge, we overwrite `X-Real-IP`, `X-Forwarded-For`, `X-Forwarded-Proto` and `X-Forwarded-Host`, replacing any copies the caller sent. `X-Forwarded-Proto` is set to `https`. We don't promise a single `X-Forwarded-For` entry or a fixed number of hops. Requests over `*.railway.internal` skip the edge, so they don't get this header handling. Any service in the same project and environment can reach your port and send its own forwarding headers. Trusting forwarded headers from every peer therefore means trusting every service in that environment, and any TCP proxy you expose. Private networks are isolated between projects and environments, so keeping the portal in an environment with no untrusted services is what limits who can reach it. TCP Proxy is raw passthrough. We don't terminate TLS or issue a certificate there, so Kestrel would handle TLS and renewal. Clients connect on the allocated external port, and no forwarding headers are added or cleaned up on that path.

rdesideri
OP

a month ago

Thank you. The portal is not resolved or enabled; no production settings have been changed. A local raw-TCP relay test now passes TLS, synthetic admin-cookie authentication, rejection of a wrong certificate/hostname, and fail-closed disconnection, but that does not validate Railway TCP Proxy. Could a Railway team member confirm whether an authenticated origin connection or a listener reachable only by the HTTP edge is available? If neither is available, please confirm whether self-managed Kestrel TLS through TCP Proxy is the supported Railway-only option for our boundary, and whether any supported option retains external port 443. We are not requesting resource or plan changes.


Status changed to Awaiting Railway Response Railway • about 1 month ago


Railway
BOT

a month ago

We don't offer an authenticated origin connection between our HTTP edge and your service, and we don't offer a listener that only the edge can reach. Services in the same project and environment can always reach your listening port over the private network, so keeping untrusted services out of that environment is the boundary we provide.

That leaves TCP Proxy as the path where Kestrel terminates TLS itself. It relays the raw byte stream to your port without terminating TLS, issuing a certificate, or adding or cleaning forwarding headers, so certificate issuance and renewal stay with your application. Your service's socket peer on that path is our proxy rather than the original client, and we don't add PROXY protocol data to the stream.

The external port for a TCP Proxy is generated by us and must be used when connecting, including with a custom domain CNAME, where only the hostname changes. No TCP Proxy configuration keeps external port 443. Standard port 443 is only available through our HTTP edge, which terminates TLS and forwards HTTP to your service, as described in our earlier reply.


Status changed to Awaiting User Response Railway • about 1 month ago


Railway
BOT

a month ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway • about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...