Skip to content
Securely distinguishing Railway public ingress from private service traffic
jcorderonovoa
OP

25 days ago

Hello Railway team,

I'm following up on the previous discussion "Supported trust model for client IP headers behind Railway HTTP ingress."

I understand that Railway overwrites X-Real-IP and X-Forwarded-For at the public edge, but that the 100.0.0.0/8 range is not guaranteed to be stable.

My application has a public Node.js frontend and a private Express backend communicating through Railway's private network.

We need to safely identify the original client IP for authentication rate limiting without allowing private services or external clients to spoof it.

Could a Railway engineer please clarify:

  1. Is there a supported and stable way for a Node.js service to distinguish requests arriving from Railway's public HTTP edge from requests originating over Railway's private network?

  2. Is there an authoritative proxy identity, trusted header, or network isolation mechanism that applications can use for this purpose?

  3. If no such mechanism exists, what architecture does Railway officially recommend for secure per-client-IP rate limiting when using a public frontend and a private backend?

  4. Can Railway guarantee that X-Real-IP and X-Forwarded-For cannot be spoofed by external clients at the public edge, including when private service-to-service traffic is enabled?

We want to avoid relying on undocumented IP ranges, arbitrary proxy-hop counts, or client-controlled headers.

An answer from Railway engineering would be greatly appreciated.

Thank you.

Solved

3 Replies

Railway
BOT

25 days ago

We don't offer a way to tell edge-forwarded requests apart from private-network requests at the application level. There's no published proxy address range, no trusted or signed edge header, no application-visible mTLS identity, and no edge-only ingress setting. Private networks are isolated between projects and environments, but inside one environment every service can reach your backend's port directly over *.railway.internal. Those requests skip the public edge and its header sanitization, so a private caller can send any X-Real-IP or X-Forwarded-For it likes.

At the public edge, we overwrite X-Real-IP, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, replacing any values the caller sent. An external client can't forge X-Real-IP through the edge, and that stays true when private networking is in use.

For your setup, do the rate limiting in the public frontend and key it on X-Real-IP. In Express, req.ip comes from trust proxy and X-Forwarded-For, not X-Real-IP, and a numeric hop count can pick up an intermediary instead of the visitor.

We don't pass the visitor's identity on to the private hop. If the frontend sends the visitor IP to the backend, that value is your own app's data, and the backend can only trust it as much as it trusts the caller. Treat the whole environment as one trust boundary, or have the backend authenticate the frontend in your own app. Keep untrusted services in a separate environment or project, and keep in mind that a TCP proxy on the backend would be another way in.


Status changed to Awaiting User Response Railway • 25 days ago


Railway

We don't offer a way to tell edge-forwarded requests apart from private-network requests at the application level. There's no published proxy address range, no trusted or signed edge header, no application-visible mTLS identity, and no edge-only ingress setting. Private networks are isolated between projects and environments, but inside one environment every service can reach your backend's port directly over `*.railway.internal`. Those requests skip the public edge and its header sanitization, so a private caller can send any `X-Real-IP` or `X-Forwarded-For` it likes. At the public edge, we overwrite `X-Real-IP`, `X-Forwarded-For`, `X-Forwarded-Proto` and `X-Forwarded-Host`, replacing any values the caller sent. An external client can't forge `X-Real-IP` through the edge, and that stays true when private networking is in use. For your setup, do the rate limiting in the public frontend and key it on `X-Real-IP`. In Express, `req.ip` comes from `trust proxy` and `X-Forwarded-For`, not `X-Real-IP`, and a numeric hop count can pick up an intermediary instead of the visitor. We don't pass the visitor's identity on to the private hop. If the frontend sends the visitor IP to the backend, that value is your own app's data, and the backend can only trust it as much as it trusts the caller. Treat the whole environment as one trust boundary, or have the backend authenticate the frontend in your own app. Keep untrusted services in a separate environment or project, and keep in mind that a TCP proxy on the backend would be another way in.

jcorderonovoa
OP

25 days ago

Thank you for the detailed response.

I understand that Railway does not provide a stable proxy CIDR or an application-visible way to distinguish public-edge requests from private-network requests.

However, I would appreciate confirmation from a Railway engineer on one remaining security concern:

If a public frontend service can also receive requests directly over Railway's private network, and those requests can contain arbitrary X-Real-IP headers, how can the frontend safely use X-Real-IP for security-sensitive authentication rate limiting without allowing another private service to spoof client identities?

Is there a supported way to restrict the frontend to public-edge ingress only while still allowing it to communicate with a private backend?

If not, is Railway's recommendation to treat all services within the environment as trusted and isolate any untrusted workloads into separate environments or projects?

We would appreciate an engineering-confirmed recommendation before deploying this security architecture.

Thank you.


Status changed to Awaiting Railway Response Railway • 25 days ago


Railway
BOT

25 days ago

We don't have a setting that limits a service to public-edge ingress only. If a service has a private network address, any other service in the same project and environment can reach its listening port directly, and those requests can carry any X-Real-IP value they like. X-Real-IP is only authoritative for requests that actually came through the public edge. Nothing in the request lets your frontend prove that a given request took that path.

So yes: treat every service in the environment as part of one trust boundary, and put untrusted workloads in a separate environment or project. Private networks are isolated between projects and environments. Within that boundary, the frontend can key authentication rate limiting on X-Real-IP, as long as only services you trust share the environment and the frontend has no other ingress path, such as a TCP proxy.

If you need stronger guarantees inside one environment, the backend has to authenticate its callers in your own application, for example with a shared secret or a signed token from the frontend. Any visitor IP the frontend passes along is then your own app's data.


Status changed to Awaiting User Response Railway • 25 days ago


Railway
BOT

18 days 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 • 18 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...