Help configuring DNS records on cloudflare for my hosted railway app
my current setup is the following :
- I have a registered domain on Godaddy
-I have a custom domain configured on railway www.example.com (should i also add example.com ?) and it detects the cloudflare proxy
- I have added my domain to cloudflare and and moved my namservers from Godaddy to Cloudflare
- cloudflar proxy is enabled and SSL also
- I added the CNAME record provided by railway (which appears after generating the custom domain) to my DNS records on cloudflare, didn't work
Initially my DNS records were automatically retrieved from Godaddy, but the thing is i changed them so many times and nothing worked.
These errors occur in the browser as i change the records:
ERR_TOO_MANY_REDIRECTS
ERR_CONNECTION_CLOSED
DNS_PROBE_FINISHED_NXDOMAIN
Note: there is a lot of config and details related to my problem, so please tell me what relevant information should i add to my post
will appreciate any help ! because i'm really stuck and confusing
79 Replies
Project ID:
1c1bc2ab-22ee-42c2-b5bd-effd164ad5db
show me a screenshot of the domains in the railway service and the DNS settings in cloudflare, so I can understand how you currently have everything setup
1c1bc2ab-22ee-42c2-b5bd-effd164ad5db
domains in railway :
screenshots please
DNS settings in cloudflare :
can you send me the railway domain, and your domain in a text?
as clickable links please
railway domain : blnbeapd.up.railway.app
as clickable links please
it wasn't provided as a link
it was provided as a text only
make it a link, I am on mobile and I can't copy specific text from a message
the original railway domain, not the obstacated domain
which one do you mean ? the one generated for my custom domain ?
no, I don't want the domain that was generated for the cname
I want the original railway domain
I am not sure, but do you mean this ?
real otakus
The place for real anime enthusiasts
now i want the same app resulted from the link above to be accessible from my custom domain www.realotakus.com
what kind of app is this?
It's Django app hosted on Railway , the client side is React.js
don't worry, we will do that, there's some prerequisites we need to do before that though
do you have two railway services? one for frontend and one for backend?
no
just one
so django is serving the frontend?
can you show me the code that serves the frontend please
so i don't need to worry about cors requests
how is that relevant ?
trust me please
it is just a function in views.py file
def react_app(request):
if request.user.is_superuser:
return redirect(f"/{ADMIN_PANEL_PATH}")
return render(request, "index.html")
or which exact part you need ?
that is an okay-ish way to do it, but you are telling django to render the index.html file and the index.html file is not a template so you waste time
change that code ever so slightly to just send an index.html file without any rendering
it was done that way in a Guide to link React to django
I know
it was not a good guide
but anyway i can change it later, no problem
yes maybe
but is it relevant now ?
not really, I'm just trying to help you to the best of my abilities while on mobile
I really appreciate it !
as long as I know you'll change it to sending just the html file without trying to render something that can't be rendered, I'm happy
because it's not a django template ?
you mean i'ts an extra usless step to render?
yes and yes
exactly
okay but moving on
in cloudflare, set your ssl/tls mode to full
like so
done
there wasn't a save button though
but i refresh the page and it's Full
ok there is good news
the browser shows different error now
different error means there is at least a progress 😅
Bad Request (400)
let me look, one sec
btw there were 2 DNS records that i deleted from my DNS records : one of them mapps to ip address of Godaddy
good, keep that deleted
this may help you with the 400
https://stackoverflow.com/a/19875816
the other was CNAME with www as Name and maps to realotakus.com
do you want a non www domain?
ok before looking at stackover flow post, do i need to edit my cloud DNS records ?
i really don't know, what is the recommened or most typical ?
it's 2023, I don't know why you even have a www subdomain to begin with
my recommendation would be to forego the www altogether and just simply have domain.com instead of www.domain.com
so should i delete my current custom domain on railway and make another one with just realotakus.com
www gets appended automatically by the browser right ?
no
this link http://realotakus.com/ links to Godaddy parken domain page !
which is not what we want of course
i know
yes or no, do you need/want a www subdomain
i will discard it for now
to keep things simple
so for now, no i don't want it
then delete it from both railway and cloudflare
then add back your root domain, to railway, then use the provided cname in cloudflare
yes, i will
ok done
good
and railways domains?
the browser now doesn't show my the 400 error
also good
but realotakus.com unexpectedly closed the connection.
thats not going to specifically be a railway issue, you will have to do some research and debugging on your own, I wish you the best of luck in solving this issue! have a nice day 🙂
so no final thoughts or things to try at least ?
I am not actually a django dev, or even a python dev for that matter, any further help I would provide would just be me relaying information that I would find through Google, so let's take the middleman out of this (me) and have you just do the research
i'm 99 % sure that this is not django related
I am 100% sure it is not a railway specific issue
ok no problem i will do my reaserach
I wish you good luck!
but latly my cloudflare DNS records don't need change right ?
those look good to me
Thank Brody for your help and time
Thanks
no problem, have a nice day!
It worked ! took a long time to show the 400 bad request again which is solved by adding realotakus.com to allowed_hosts
im glad to hear it, i knew you would solve it fast!
Thanks to me, and really Thanks to you !
joint effort 🙂
mostly you though
the most confusing part was the browser errors were not consistent and keep changing even if don't change the config
or maybe things take their time to take effect
web dev hard