Cloudflare load balancing between regions

I'm trying to setup a cloudflare loadbalancer to route traffic by location between different services on Railway (EU and US-West). I'm having some problems configuring it, I'de really appreciate any help!!
No description
No description
197 Replies
Percy
Percy7mo ago
Project ID: dd3f96f7-3ab3-4453-86a3-32328b2f81d6
macwilko
macwilko7mo ago
dd3f96f7-3ab3-4453-86a3-32328b2f81d6 When I try resolve the root domain I get:
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
so I have the load balancer setup now, and it thinks the origin servers are healthy
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
Feels like it might be a TLS error I occasionally see this page then this page
macwilko
macwilko7mo ago
No description
Brody
Brody7mo ago
railway uses the host to know what service to route traffic to, so it sees wikid.app and doesn't know where to send it to, somehow you'd need to get cloudflare to set the host to whatever origin it decides to proxy to
macwilko
macwilko7mo ago
brody!! thankyou so this is the little bit confusing thing let me show you
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
in the load balancer, it is configured for the domain wikid.app it has two origins configured, one for eu, one for us I tried configuring it for railway generated domains, and it seems to kinda work
Brody
Brody7mo ago
I don't even know if what I said is possible in cloudflare, I only know thats why it doesn't work
macwilko
macwilko7mo ago
yeah.. it's strange it seems like the service in railway needs to be configured to respond to wikid.app but this shouldn't be needed since cloudflare should be responsible for the routing to services
Brody
Brody7mo ago
I have only ever seen a host mask option with fastly and that was not with a load balancer
macwilko
macwilko7mo ago
is it possible to ask the team on monday if this is possible with railway? cloudflare load balancing across regions
Brody
Brody7mo ago
it is possible, one way or another, they even mention it in the docs
macwilko
macwilko7mo ago
sweet ok that's promising
Brody
Brody7mo ago
that also means you'd need to provide your own certs for wikid.app, since railway isn't in charge of that domain anymore
macwilko
macwilko7mo ago
i see, i believe cloudflare can also do this right?
Brody
Brody7mo ago
I honestly don't know
macwilko
macwilko7mo ago
i know i'm kinda poking at the extremes of what's possible here with railway but it would be so nice to have eu / us regions working
Brody
Brody7mo ago
haha no you're not, if cloudflare has a way to issue a cert for your domain and set the host to the upstream domain then you'd be done by now
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
No description
Brody
Brody7mo ago
to install on your server is not applicable here
macwilko
macwilko7mo ago
yeah >.< that's what's confusing, i thought cloudflare was already sorta doing this
Brody
Brody7mo ago
1. railway isn't your server 2. cloudflare is the server now that they're doing the lb
macwilko
macwilko7mo ago
right exactly but i just need to route traffic to railway the load balancer i think normally takes an IP or a hostname but it doesn't seem like railway router supports this setup it doesn't know how to handle it
Brody
Brody7mo ago
try with Fastly, they let you set conditions and you also should be able to set the host
macwilko
macwilko7mo ago
damn, i'd like to try get it to work with cloudflare since I'm using alot of their products. It's also not clear to me if fastly would work either
Brody
Brody7mo ago
well keep messing around with cloudflare then, but with fastly you can write your own logic
No description
macwilko
macwilko7mo ago
i can't see how that's different to cloudflare
Brody
Brody7mo ago
can you write logic like that in cloudflare?
macwilko
macwilko7mo ago
i could show you in VC maybe?
Brody
Brody7mo ago
I don't like VC
macwilko
macwilko7mo ago
ahh i remember lol
Brody
Brody7mo ago
but you now know your two blockers, so play around some
macwilko
macwilko7mo ago
damn, well. idk honestly. I'm lost on that
Brody
Brody7mo ago
try to solve it the same way I would, google stuff and run around in the cloudflare dashboard
macwilko
macwilko7mo ago
fair. I'll give it another shot. Although, I personally think the things I have tried, leads me to believe this isn't possible yet the clue for me this this bit:
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
configuring the domain wikid.app in railway shouldn't be required
Brody
Brody7mo ago
I'm not sure if I'd even be able to test something like this, I don't subscribe to any vpn services so that I could switch regions
macwilko
macwilko7mo ago
but it seems like it is currently i'm seeing all the traffic routed to US servers
Brody
Brody7mo ago
to get an ssl cert it's required, but like I said you need to provide your own cert since railway is no longer going to be the one routing traffic railway is not going to have anything to do with the root domain wikid.app for what you want
macwilko
macwilko7mo ago
no 😦 i don't think fastly or cloudflare can help it's a limitation of railway router
Brody
Brody7mo ago
you're giving up too easily and worst of all you're blaming railway
LaCrak27
LaCrak277mo ago
just found this null lmao
No description
LaCrak27
LaCrak277mo ago
but mac, there has to be a way even if its slightly janky lma
macwilko
macwilko7mo ago
^.^
Brody
Brody7mo ago
someone give me their login to a vpn provider already
LaCrak27
LaCrak277mo ago
Don't lose HOPE!
macwilko
macwilko7mo ago
proton has a free vpn
LaCrak27
LaCrak277mo ago
i use tunnelbear for free for sus things
macwilko
macwilko7mo ago
hehe
LaCrak27
LaCrak277mo ago
the free 2 gigs are enough (monthly)
Brody
Brody7mo ago
gross
macwilko
macwilko7mo ago
but you don't need a vpn for this lol 😄
LaCrak27
LaCrak277mo ago
? oh fuck i just realized what you thought i don't mean stuff like porn
macwilko
macwilko7mo ago
ahaha
LaCrak27
LaCrak277mo ago
with sus things
macwilko
macwilko7mo ago
like... netflix
Brody
Brody7mo ago
how would I test region routing if I can't make a request from a different region
LaCrak27
LaCrak277mo ago
i mean like tryna get access to bard while being in spain and under 18 kinda sus things
macwilko
macwilko7mo ago
at least in cloudflare you can set the proximity via a map:
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
you could drag this map and route all US traffic to the EU origin lol if you wanted
LaCrak27
LaCrak277mo ago
i can one hundred percent see a company accidentally running like that and not noticing
macwilko
macwilko7mo ago
hehe yeah... ! boss, our latency just jumped 200%! no idea why...
LaCrak27
LaCrak277mo ago
lmfao fr
Brody
Brody7mo ago
that's not how you'd have it actually setup in the end so I wouldn't do that myself
macwilko
macwilko7mo ago
fair proton vpn is pretty solid and free
Brody
Brody7mo ago
is their free version gonna ask me to upgrade every minute
macwilko
macwilko7mo ago
nope i've used it for years, never paid
Brody
Brody7mo ago
can I put a subdomain in cloudflare without having to setup the nameservers
macwilko
macwilko7mo ago
i beleive for cloudflare to work, you need to configure the name servers so cloudflare can proxy requests right? on wikid.app that was the first step I needed to do for configuring cloudflare
Brody
Brody7mo ago
so if i wanted to test region lb with cloudflare id need another domain, i only own one and im not changing the nameservers on it
LaCrak27
LaCrak277mo ago
i can let you test a domain
macwilko
macwilko7mo ago
oof. I mean you're welcome to play around with my cloudflare account
LaCrak27
LaCrak277mo ago
just bought it yesterday and i have no use for it whatsoever (for now)
Brody
Brody7mo ago
is it a sus domain
macwilko
macwilko7mo ago
israsist .com
Brody
Brody7mo ago
me omw to check mod log to see if you said something worse before you said that
macwilko
macwilko7mo ago
LOL anyways no rush on this 😒 it's about to be christmas, and it's your birthday brody lol... i wasn't expecting this to be solved today tbh
LaCrak27
LaCrak277mo ago
nope, omnibot.es i think
Brody
Brody7mo ago
what are its current nameservers
LaCrak27
LaCrak277mo ago
or was it .com... i have no idea just bought it and it is .es should be nominalia's ones
LaCrak27
LaCrak277mo ago
No description
LaCrak27
LaCrak277mo ago
why is there an ftp subdomain lmfao
No description
LaCrak27
LaCrak277mo ago
@Brody
Brody
Brody7mo ago
hmmm now could i just add that to my cloudflare account?
LaCrak27
LaCrak277mo ago
hold up lemme get brodyiscool.online and give that to you xd bc i will use this one this xmas
Brody
Brody7mo ago
lmao dont go buying a domain for this
LaCrak27
LaCrak277mo ago
its free for me like a weird offer but if you promise to give it back after youre done you can use that one
Brody
Brody7mo ago
i mean ofc but i think id only be giving you nameservers to set on it, we arent doing a domain transfer
macwilko
macwilko7mo ago
i have a domain we can do that on wilko.dev
LaCrak27
LaCrak277mo ago
oh if its only that we can do it or even better on mac's one whichever one you choose :)
macwilko
macwilko7mo ago
ty lacrak, you're awesome buddy send me NS
LaCrak27
LaCrak277mo ago
you mean that to brody right? btw please don't take this to DMs, i wanna see how this is done incase i do need to use railway for something like this one day
Brody
Brody7mo ago
ill go with mac's domain getting ns now
kanye.ns.cloudflare.com
tricia.ns.cloudflare.com
kanye.ns.cloudflare.com
tricia.ns.cloudflare.com
macwilko
macwilko7mo ago
ok
LaCrak27
LaCrak277mo ago
very interesting nameservers
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
should be done!
LaCrak27
LaCrak277mo ago
actually if you point 2 domains to the exact same nameservers they just act as one right? or does the ssl cert freak out...
Brody
Brody7mo ago
no clue
Brody
Brody7mo ago
not impressed
No description
LaCrak27
LaCrak277mo ago
LMAO
macwilko
macwilko7mo ago
no way how comes mine is free then?
LaCrak27
LaCrak277mo ago
tunnelbear is still free
Brody
Brody7mo ago
mine is free, it just wants me to upgrade
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
ahh
LaCrak27
LaCrak277mo ago
and i haven't noticed any push to upgrade
Brody
Brody7mo ago
did you just leak your ip lmao
LaCrak27
LaCrak277mo ago
eh just replug router its fine :)
macwilko
macwilko7mo ago
if this works
Brody
Brody7mo ago
nah just press the renew button in your routers settings
No description
macwilko
macwilko7mo ago
i bet you wikid app will have the fastest api, on railway no joke
LaCrak27
LaCrak277mo ago
(inb4 2940ms latency)
macwilko
macwilko7mo ago
hehe
LaCrak27
LaCrak277mo ago
(i'm joking dw) i mean if i end up working with you that would become my problem lmfoa
macwilko
macwilko7mo ago
brody i can send you my CF credentials if that helps you won't have a load balancer without $15 >.<
Brody
Brody7mo ago
no i think the nameservers are sufficent, im just setting up the two region services right now
macwilko
macwilko7mo ago
i see ok
Brody
Brody7mo ago
oh, then yeah id need the creds if it isnt on free
macwilko
macwilko7mo ago
right, one sec, will DM you those
LaCrak27
LaCrak277mo ago
can i have em too 😳
Brody
Brody7mo ago
ive removed wilko.dev from my account, go ahead and add that to your own cloudflare account context: i now have access to his account
macwilko
macwilko7mo ago
sweet
macwilko
macwilko7mo ago
you should see wikid.app then goto Traffic I think on the left
Brody
Brody7mo ago
and it comes with dark mode on, how thoughtfull
macwilko
macwilko7mo ago
there's a section for Argo and Load balancers
Brody
Brody7mo ago
erm
No description
macwilko
macwilko7mo ago
ooo you need access to anythign else?
Brody
Brody7mo ago
haha no, i have pro, it was just missing with the new ui
macwilko
macwilko7mo ago
oh lol
Brody
Brody7mo ago
im going to get the basics working before i touch wikid.app
https://region-eu.up.railway.app/
https://region-as.up.railway.app/
https://region-eu.up.railway.app/
https://region-as.up.railway.app/
macwilko
macwilko7mo ago
alright 🙂 🤞
Brody
Brody7mo ago
oh for me to add wilko.dev youd need to pay again lol
macwilko
macwilko7mo ago
just fiddle with wikid app 😄
Brody
Brody7mo ago
doesnt matter if i mess something up?
macwilko
macwilko7mo ago
nobody's gonna mind if it goes down nah, it's a toy project atm, not even released yet i've removed wikid.app domain from my Railway project
Brody
Brody7mo ago
ill just be digging around the ui for a bit
macwilko
macwilko7mo ago
no worries you can get lost in cloudflare lol so many settings starting to feel like AWS console
Brody
Brody7mo ago
proton not gonna work, need something else unless its just the chrome extension
macwilko
macwilko7mo ago
hmm maybe I can hit the end point for you? i'm in europe where should i visit? ooo
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
is it working?
Brody
Brody7mo ago
visit from singapore
macwilko
macwilko7mo ago
wikid.app is resolving to a EU railway from my location that's ... promising !! ok
Brody
Brody7mo ago
its the fallback pool so dont get excited
macwilko
macwilko7mo ago
i will goto singapore one sec wow
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
i think you did it AS
Brody
Brody7mo ago
and you where ready to give up lol
macwilko
macwilko7mo ago
O.O how tf did you do that
Brody
Brody7mo ago
im built diff
macwilko
macwilko7mo ago
yeah. please explain what you did lol
Brody
Brody7mo ago
well you see... i took my own advice
macwilko
macwilko7mo ago
O.O idk personally I think you're just pretty good at the networking stuff it's not my skill, i'm happy to own that lol
Brody
Brody7mo ago
most literally, exactly what i said
No description
LaCrak27
LaCrak277mo ago
lmao nice
macwilko
macwilko7mo ago
oo its the host header?
LaCrak27
LaCrak277mo ago
ay
No description
macwilko
macwilko7mo ago
honestly i would of never guessed that not in a million years
LaCrak27
LaCrak277mo ago
he did tell you tho lmfao
Brody
Brody7mo ago
was right from the very start
macwilko
macwilko7mo ago
also.. i'm bad at reading argh i see >.< yeah... mb can i play around with cloudflare now brody? ;-D i wanna configure wikids regions for it
Brody
Brody7mo ago
go for it
Brody
Brody7mo ago
service groups is perfect for this kind of thing
No description
macwilko
macwilko7mo ago
ooo i'm gonna try it!! man it's not obvious how to enable that trying to figure that out lol
Medim
Medim7mo ago
This entire thread made into a portfolio blog post would be super cool nice tutorial here
Brody
Brody7mo ago
maybe
macwilko
macwilko7mo ago
^.^ could be... something cool
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
how do you like group them together with the coloured background? i can move them around but i can't seem to colour them
Brody
Brody7mo ago
right click on the service
macwilko
macwilko7mo ago
ooo got it damn
Brody
Brody7mo ago
or just on the canvas, I forgot
macwilko
macwilko7mo ago
No description
macwilko
macwilko7mo ago
bro ok i just need to get the planetscale database hooked up
LaCrak27
LaCrak277mo ago
ay that looks nice as hell how expensive is it to run tho 💀 can't be cheap at all
macwilko
macwilko7mo ago
i think must be about $100/m i think database / cloudflare / railway
LaCrak27
LaCrak277mo ago
DAMn
Medim
Medim7mo ago
imo that's fairly priced considering all that infra thonk
macwilko
macwilko7mo ago
yeah totally i'm not complaining i think most of the bill is on cloudflare stuff tbh
Brody
Brody7mo ago
thank you for the trains!!! ❤️
macwilko
macwilko7mo ago
you deserve way more.
Brody
Brody7mo ago
awe thank you
Dmitry
Dmitry7mo ago
Brody helping other people on his birthday 😭 You're the best!
Brody
Brody7mo ago
yeah and I'll be here on Christmas too
Dmitry
Dmitry7mo ago
You're too good to us 😩
LaCrak27
LaCrak277mo ago
i will also be snoopin in here lmao