Skip to content
Safely distinguishing Railway public ingress from private callers when using X-Real-IP
canacio
OP

a month ago

Hello Railway team,

We’re reviewing client-IP handling for application rate limiting in a Node.js/Fastify application using Better Auth.

Our topology is:

Cloudflare DNS-only CNAME → Railway public HTTP ingress → application

We reviewed staff guidance recommending X-Real-IP for public-ingress requests, while noting that private-network requests bypass edge-header sanitization.

Could Railway staff clarify two remaining points?

  1. Public-ingress versus private/direct callers
  • Can private-network callers reach the same application listener and supply their own X-Real-IP?
  • What supported mechanism distinguishes public-ingress requests from private/direct requests before trusting that header?
  • Can private inbound access be restricted while preserving application-to-database connectivity?
  • If there is no authenticated per-request distinction, what architecture does Railway recommend?

We would not treat Host, observed internal IP ranges, or a fixed proxy-hop count as proof of trusted ingress.

  1. Railway-managed CDN behavior

An older staff discussion described cases where X-Real-IP represented a CDN edge rather than the original client.

  • Is that behavior resolved?
  • Can it affect DNS-only custom domains, without Cloudflare proxying?
  • Can Railway-managed CDN routing participate in that path?
  • What current exceptions should applications account for when using X-Real-IP for rate limiting?

We’re seeking the supported current trust model, including any differences between generated and custom domains.

Thank you.

Solved

1 Reply

Railway
BOT

a month ago

Yes, private callers can reach the same listener. Any service in the same project and environment can connect to your app's port over *.railway.internal without going through the public edge, so it can send its own X-Real-IP. There is no edge-only ingress switch, signed forwarding header, or per-request identity your app can check to tell a public request from a private one. Your private network is isolated per project and environment, so every service in that environment is inside your trust boundary. Edge Rules filter only traffic on public domains, so they can't restrict private inbound access.

For requests that come through the public edge, we overwrite X-Real-IP, X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host, so a caller can't choose the value by sending a forged copy. This works the same way for generated domains and DNS-only custom domains.

When CDN caching is enabled on a service, X-Real-IP is set to the original client IP, not the CDN node. That applies to both generated and DNS-only custom domains. The other exception is Cloudflare. If a request reaches us from Cloudflare's published IPv4 ranges with CF-Connecting-IP, X-Real-IP takes that value. In your DNS-only setup, Cloudflare isn't in the request path.

X-Forwarded-For doesn't have a fixed hop count, and the proxy socket address isn't a stable or published range, so neither should be treated as proof of trust.


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


Railway
BOT

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


Welcome!

Sign in to your Railway account to join the conversation.

Loading...