Setup Cloudflare Proxy
1. Clicked "custom domain".
2. Railway pops up a CNAME for me to add to Cloudflare.
3. Add CNAME record to Cloudflare.
4. Railway says "Cloudflare proxy detected" indicating it knows about the DNS change.
5. Test out domain and its dead, returns a 522.
6. Go back to Railway and test if generating a domain works.
7. It does. Generated domains work, so I know the app is serving correctly. Railway says it detects cloudflare DNS but Cloudflare is giving me 522s.
32 Replies
Project ID:
N/A
can you send the custom and railway domain in question?
I am trying this pattern with a few projects but here's one of he broken ones.
Broken
https://rulabs.dev/
Works
rulabs-production.up.railway.app
what kind of app is that?
Static site
React app
create react app?
No, was generated with NX, but its just a vite react app, static site in the end
okay vite, cool. i suspect theres something going wrong with http-server, can we get you setup with a proper http server like caddy?
ah, ok, i'll try that out then
maybe i can use railway static here?
would you want to add me to your repo so i can figure out to integrate my pre-existing caddy solution?
nope, it can not serve SPA apps
yeah happy to, this is kinda a sandbox experiment so you can't break anything. i moved a few of our apps to this monorepo to test. see the package.json on how to build stuff. lmk your gh
brody192
huh weird, some error about org seats. I made it public for a bit
https://github.com/ru-labs/rulabs
GitHub
GitHub - ru-labs/rulabs
Contribute to ru-labs/rulabs development by creating an account on GitHub.
i assume you have
build:the76devs
and start:the76devs
set in the service settings on railway?yep! previously i was trying with npx nx build the76devs but railway threw errors at that so i only made the package scripts to get past that
which idk why, this other app i have from another repo works fine
cool, ill see about doing a pr that will integrate caddy
sweet thanks! and curious to see if there will be much extra to do when adding more apps in the future
ill try to make it as non intrusive as possible
for the changes in the PR to work you just need to add a
NIXPACKS_CONFIG_FILE
service variable set to apps/the76devs/nixpacks.toml
on the "the76devs" service, and the same variable set to apps/rulabs/nixpacks.toml
on the "rulabs" service.
as far as i can tell, everything else can stay the same.
PR: https://github.com/ru-labs/rulabs/pull/1
test sites with cloudflare proxies: https://the76devs.railyard.link/ and https://rulabs.railyard.link/very cool! will play with this when home. Since all apps in this monorepo follow the same pattern I wonder if there's a way to share the same config
every app will/should be built to dist/apps/appname
but i can play with that. thanks again
no problem!
just thought of something. i could probably use caddy to host a spa and make it ignore hashrouting huh 👀 sometimes i have those like small 2 route apps that would be just fine like that
why do you need to ignore hash routing?
cleaner urls, can then do a URL + a hash while still only having client side app. There's some things with history you lose when using hash routes too i think. its a more rare case for sure. more so just wanted to try it out
why not do just regular page routing?
your change worked! or was a part of the puzzle. after the change i was getting "too many redirects", and had to change my cloudflare ssl settings from "flexible" to "full".
yep that is indeed needed https://docs.railway.app/guides/public-networking#provider-specific-instructions