a month ago
This is a pre-deployment networking/security question. We have not created a Railway service yet, so there are no deployment logs or service errors.
We are preparing a Node.js/Express application behind Railway Public Networking. It uses request information for HTTPS enforcement, secure sessions, Host/origin validation, and client-IP rate limiting.
We need confirmation of these security guarantees:
-
Does Railway remove or overwrite client-supplied X-Real-IP, X-Forwarded-Proto, and X-Forwarded-Host headers before forwarding requests? How are duplicate headers and comma-separated values handled?
-
Is X-Real-IP guaranteed to contain the client IP observed by Railway’s edge? How does Railway construct X-Forwarded-For, and which header should Express applications use for reliable client-IP rate limiting?
-
Can requests reach the application’s listening port without passing through Railway’s public edge—for example, through private networking or another ingress path?
-
Does Railway publish stable immediate-proxy IP addresses/CIDRs, or another supported mechanism for identifying trusted proxies?
-
If no proxy CIDR list exists, what secure Express trust proxy configuration does Railway officially recommend, and what deployment conditions make it safe?
-
Is app.set('trust proxy', 1) officially safe for a single Railway public-edge-to-application deployment? Is that hop count guaranteed across all ingress paths, or should applications use another approach?
We want to avoid trusting forwarding headers that an end user can spoof. Please provide confirmation from Railway staff or authoritative documentation. This is a networking-guarantees question, not an application debugging request.
3 Replies
a month ago
Our HTTP edge overwrites X-Real-IP, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host on every request it forwards. Caller-supplied copies are replaced, not appended to, so duplicate or comma-separated values a client sends are not passed through. X-Real-IP is the client's remote IP as seen by the edge, X-Forwarded-Proto is https, and X-Forwarded-Host is the original Host header. For client-IP rate limiting, X-Real-IP is the header to use. One exception: when the connection comes from Cloudflare's published IPv4 ranges and carries CF-Connecting-IP, X-Real-IP is set to that value.
The edge is not the only path to your listening port. Services in the same project and environment can reach it directly over private networking (*.railway.internal), and those requests are not sanitized, so a private caller can set any forwarding headers it likes. A TCP proxy, if you add one, also forwards raw bytes without HTTP header handling.
We do not publish a stable range for the proxy addresses your app sees as the socket peer. Do not hard-code an observed range. We also do not guarantee a fixed hop count or a single-entry X-Forwarded-For, so trust proxy = 1 is not an official guarantee. In a multi-hop setup it can pick an intermediary. Express's req.ip is built from the socket peer and X-Forwarded-For, not from X-Real-IP.
Reading X-Real-IP directly is safe when every path to the listener is trusted. In practice that means no untrusted services in the same environment and no separate raw ingress. See the public networking specs and our private networking overview.
Status changed to Awaiting User Response Railway • about 1 month ago
Railway
Our HTTP edge overwrites `X-Real-IP`, `X-Forwarded-For`, `X-Forwarded-Proto` and `X-Forwarded-Host` on every request it forwards. Caller-supplied copies are replaced, not appended to, so duplicate or comma-separated values a client sends are not passed through. `X-Real-IP` is the client's remote IP as seen by the edge, `X-Forwarded-Proto` is `https`, and `X-Forwarded-Host` is the original Host header. For client-IP rate limiting, `X-Real-IP` is the header to use. One exception: when the connection comes from Cloudflare's published IPv4 ranges and carries `CF-Connecting-IP`, `X-Real-IP` is set to that value. The edge is not the only path to your listening port. Services in the same project and environment can reach it directly over private networking (`*.railway.internal`), and those requests are not sanitized, so a private caller can set any forwarding headers it likes. A TCP proxy, if you add one, also forwards raw bytes without HTTP header handling. We do not publish a stable range for the proxy addresses your app sees as the socket peer. Do not hard-code an observed range. We also do not guarantee a fixed hop count or a single-entry `X-Forwarded-For`, so `trust proxy = 1` is not an official guarantee. In a multi-hop setup it can pick an intermediary. Express's `req.ip` is built from the socket peer and `X-Forwarded-For`, not from `X-Real-IP`. Reading `X-Real-IP` directly is safe when every path to the listener is trusted. In practice that means no untrusted services in the same environment and no separate raw ingress. See the [public networking specs](https://docs.railway.com/networking/public-networking/specs-and-limits#technical-specifications) and our [private networking overview](https://docs.railway.com/networking/private-networking/how-it-works).
a month ago
Thank you. Before relying on these guarantees for security controls, could a Railway staff member confirm the AI response above, particularly:
- The overwrite behavior for all four forwarding headers, including duplicate/comma-separated values and the Cloudflare exception.
- The absence of stable proxy CIDRs and a guaranteed hop count.
- Whether our proposed topology—one Node app and one private MySQL service in an isolated environment, with no TCP proxy or other ingress—is sufficient for safely using X-Real-IP and X-Forwarded-Proto.
- Whether Railway offers a supported way to distinguish edge-forwarded HTTP requests from direct private-network requests.
Please provide staff confirmation or authoritative documentation for these guarantees.
Status changed to Awaiting Railway Response Railway • about 1 month ago
Status changed to Awaiting User Response brody • about 1 month ago
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