Connecting a load balancer
dudoska
HOBBYOP

8 months ago

Hello

I’m experiencing an issue where users from Russia are having trouble loading my website, which is hosted on Railway. Currently, the only solution I can think of is to use a load balancer.
However, the problem is that the load balancer service I’m considering only accepts IP addresses for backend servers, while Railway only provides a domain name, not a static IP address.
Are there any possible workarounds for this?

(For context: my site is built with Node.js + Express and uses Cloudflare)

$10 Bounty

6 Replies

dudoska
HOBBYOP

8 months ago

788b4f6a-a57a-40e3-9423-2d295860a463


ysmnababan
FREE

8 months ago

You might want to try using Cloudflare Tunnel—it's a pretty handy way to connect your app to Cloudflare without needing a static IP address.

Basically, instead of exposing your Railway app directly to the internet, you run a small service (called cloudfared) from inside your app. This creates a secure tunnel out to Cloudflare. From there, Cloudflare takes care of routing traffic to your app.

The cool thing is that your app stays hidden behind Cloudflare, which helps with both reliability and security—and you don’t need to worry about IP addresses anymore.

To set it up:

  • You’ll need to install and run cloudflared from within your Railway project (this might require Docker).

  • Then you create a tunnel from your app to Cloudflare.

  • Cloudflare gives you a unique hostname (something like app.cloudflare-tunnel.com) that you can use to route traffic.


dudoska
HOBBYOP

8 months ago

Thanks for the answer ysmnababan, but unfortunately this method is not suitable for me.
The solution was to move my specific project to Russian servers.


dikaaajs
FREE

8 months ago

Yeah, I’ve hit this before too — Railway doesn’t give you a fixed IP, so most traditional load balancers that expect backend IPs just won’t work out of the box.

Since you’re already using Cloudflare, honestly your best bet is probably Cloudflare Tunnel. It works really well with Railway and gets around the IP limitation completely.

Basically, you run cloudflared inside your Railway app (via a side process or Docker), and it creates a tunnel out to Cloudflare. That gives you a stable Cloudflare endpoint (like yourapp.cloudflare-tunnel.com) and from there you can do load balancing, geo-routing, whatever — all from Cloudflare’s side.

It also tends to be more reliable for regions like Russia where direct Railway access can be patchy. Cloudflare has better edge coverage, so traffic gets routed more effectively.

Only catch is: Railway doesn’t have official support for background workers or side processes yet, so running cloudflared inside the same container takes a bit of Docker fiddling. But it’s doable.

If you don’t want to go that route, the only real option is to host your backend on a platform that gives you a static IP (like Fly.io, Render, or just a VPS), and then forward from there. But then you lose all the simplicity of Railway.


danny
PRO

8 months ago

What you could also do to simplify is setup a Cloudflare Redirect Rule to redirect Russian users to a different subdomain: https://developers.cloudflare.com/rules/url-forwarding/single-redirects/create-dashboard/


dikaaajs

Yeah, I’ve hit this before too — Railway doesn’t give you a fixed IP, so most traditional load balancers that expect backend IPs just won’t work out of the box.Since you’re already using Cloudflare, honestly your best bet is probably Cloudflare Tunnel. It works really well with Railway and gets around the IP limitation completely.Basically, you run cloudflared inside your Railway app (via a side process or Docker), and it creates a tunnel out to Cloudflare. That gives you a stable Cloudflare endpoint (like yourapp.cloudflare-tunnel.com) and from there you can do load balancing, geo-routing, whatever — all from Cloudflare’s side.It also tends to be more reliable for regions like Russia where direct Railway access can be patchy. Cloudflare has better edge coverage, so traffic gets routed more effectively.Only catch is: Railway doesn’t have official support for background workers or side processes yet, so running cloudflared inside the same container takes a bit of Docker fiddling. But it’s doable.If you don’t want to go that route, the only real option is to host your backend on a platform that gives you a static IP (like Fly.io, Render, or just a VPS), and then forward from there. But then you lose all the simplicity of Railway.

pernydev
HOBBY

8 months ago

Please stop AI generating responses to try to get bounties, you will be banned.


Loading...