Skip to content
Authenticating public edge traffic vs private service traffic for IP rate limits
ronnanfitness-cloud
OP

3 hours ago

Hello Railway community,

How can an application safely identify the original client IP for security-sensitive rate limiting when it receives both public HTTP edge requests and private-network requests?

In an isolated test, the public edge replaced spoofed X-Real-IP and X-Forwarded-For values. In a separate private-network test, a service could send arbitrary values in these headers to another service. The observations are limited to those tests.

I have read Railway's public explanation that there is no signed edge identity or edge-only listener setting, and that services in the same project/environment share a private network. Is this still the supported model? If so, what architecture is recommended to make IP-based authentication rate limits resistant to spoofing, especially when a gateway also needs access to Redis or a backend in the same environment?

How should a backend authenticate a gateway and protect a client IP passed on the private hop? Are there caveats for IPv6, CDNs, duplicate headers, or changes to Railway's edge behavior? Links to current official documentation would be appreciated.

No project or service identifiers, credentials or customer data are included. Thank you.

Awaiting User Response

1 Reply

Railway
BOT

3 hours ago

Yes, that is still the model. Our HTTP edge overwrites X-Real-IP, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, replacing any copies the caller sends. For public traffic, use X-Real-IP as the client IP rather than the socket peer, which is a proxy address. We don't publish a stable range for that proxy address, so don't hard-code an observed CIDR. There is no signed edge identity, application-visible mTLS, or edge-only listener setting.

Private networking traffic over *.railway.internal skips the edge and its header cleanup. Services in the same project and environment share one trust boundary and can reach each other's listening ports, so a forwarding header on a private request proves nothing. When a gateway passes a visitor IP to a backend, that IP is metadata from your application, and Railway does not restore the original visitor identity on that hop. The backend has to decide, in your own application, how far it trusts that gateway. Remember that any TCP proxy or other ingress path is another way to reach the listener.

On caveats: with Cloudflare in front, X-Real-IP comes from CF-Connecting-IP only when the connection arrives from Cloudflare's published IPv4 ranges. The Forwarded header and the IPv6 socket-peer behavior aren't defined. These details can change, as noted in the public networking specs and the private networking overview. An IP is also not a stable user identity, because users can change networks or use a VPN.


Status changed to Awaiting User Response Railway • about 3 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...