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
Percy
Percy•2y ago
Project ID: 1c1bc2ab-22ee-42c2-b5bd-effd164ad5db
Brody
Brody•2y ago
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
bedo_khaled0
bedo_khaled0OP•2y ago
1c1bc2ab-22ee-42c2-b5bd-effd164ad5db domains in railway :
Brody
Brody•2y ago
screenshots please
bedo_khaled0
bedo_khaled0OP•2y ago
bedo_khaled0
bedo_khaled0OP•2y ago
DNS settings in cloudflare :
bedo_khaled0
bedo_khaled0OP•2y ago
Brody
Brody•2y ago
can you send me the railway domain, and your domain in a text? as clickable links please
bedo_khaled0
bedo_khaled0OP•2y ago
railway domain : blnbeapd.up.railway.app
Brody
Brody•2y ago
as clickable links please
bedo_khaled0
bedo_khaled0OP•2y ago
it wasn't provided as a link it was provided as a text only
Brody
Brody•2y ago
make it a link, I am on mobile and I can't copy specific text from a message
Brody
Brody•2y ago
the original railway domain, not the obstacated domain
bedo_khaled0
bedo_khaled0OP•2y ago
which one do you mean ? the one generated for my custom domain ?
Brody
Brody•2y ago
no, I don't want the domain that was generated for the cname I want the original railway domain
bedo_khaled0
bedo_khaled0OP•2y ago
I am not sure, but do you mean this ?
bedo_khaled0
bedo_khaled0OP•2y ago
bedo_khaled0
bedo_khaled0OP•2y ago
now i want the same app resulted from the link above to be accessible from my custom domain www.realotakus.com
Brody
Brody•2y ago
what kind of app is this?
bedo_khaled0
bedo_khaled0OP•2y ago
It's Django app hosted on Railway , the client side is React.js
Brody
Brody•2y ago
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?
bedo_khaled0
bedo_khaled0OP•2y ago
no just one
Brody
Brody•2y ago
so django is serving the frontend?
bedo_khaled0
bedo_khaled0OP•2y ago
Brody
Brody•2y ago
can you show me the code that serves the frontend please
bedo_khaled0
bedo_khaled0OP•2y ago
so i don't need to worry about cors requests how is that relevant ?
Brody
Brody•2y ago
trust me please
bedo_khaled0
bedo_khaled0OP•2y ago
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 ?
Brody
Brody•2y ago
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
bedo_khaled0
bedo_khaled0OP•2y ago
it was done that way in a Guide to link React to django
Brody
Brody•2y ago
I know it was not a good guide
bedo_khaled0
bedo_khaled0OP•2y ago
but anyway i can change it later, no problem yes maybe but is it relevant now ?
Brody
Brody•2y ago
not really, I'm just trying to help you to the best of my abilities while on mobile
bedo_khaled0
bedo_khaled0OP•2y ago
I really appreciate it !
Brody
Brody•2y ago
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
bedo_khaled0
bedo_khaled0OP•2y ago
because it's not a django template ? you mean i'ts an extra usless step to render?
Brody
Brody•2y ago
yes and yes exactly okay but moving on in cloudflare, set your ssl/tls mode to full
Brody
Brody•2y ago
Brody
Brody•2y ago
like so
bedo_khaled0
bedo_khaled0OP•2y ago
bedo_khaled0
bedo_khaled0OP•2y ago
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)
Brody
Brody•2y ago
let me look, one sec
bedo_khaled0
bedo_khaled0OP•2y ago
btw there were 2 DNS records that i deleted from my DNS records : one of them mapps to ip address of Godaddy
Brody
Brody•2y ago
good, keep that deleted this may help you with the 400 https://stackoverflow.com/a/19875816
bedo_khaled0
bedo_khaled0OP•2y ago
the other was CNAME with www as Name and maps to realotakus.com
Brody
Brody•2y ago
do you want a non www domain?
bedo_khaled0
bedo_khaled0OP•2y ago
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 ?
Brody
Brody•2y ago
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
bedo_khaled0
bedo_khaled0OP•2y ago
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 ?
Brody
Brody•2y ago
no
bedo_khaled0
bedo_khaled0OP•2y ago
this link http://realotakus.com/ links to Godaddy parken domain page ! which is not what we want of course
Brody
Brody•2y ago
i know yes or no, do you need/want a www subdomain
bedo_khaled0
bedo_khaled0OP•2y ago
i will discard it for now to keep things simple so for now, no i don't want it
Brody
Brody•2y ago
then delete it from both railway and cloudflare then add back your root domain, to railway, then use the provided cname in cloudflare
bedo_khaled0
bedo_khaled0OP•2y ago
yes, i will ok done
bedo_khaled0
bedo_khaled0OP•2y ago
Brody
Brody•2y ago
good and railways domains?
bedo_khaled0
bedo_khaled0OP•2y ago
bedo_khaled0
bedo_khaled0OP•2y ago
the browser now doesn't show my the 400 error
Brody
Brody•2y ago
also good
bedo_khaled0
bedo_khaled0OP•2y ago
but realotakus.com unexpectedly closed the connection.
Brody
Brody•2y ago
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 🙂
bedo_khaled0
bedo_khaled0OP•2y ago
so no final thoughts or things to try at least ?
Brody
Brody•2y ago
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
bedo_khaled0
bedo_khaled0OP•2y ago
i'm 99 % sure that this is not django related
Brody
Brody•2y ago
I am 100% sure it is not a railway specific issue
bedo_khaled0
bedo_khaled0OP•2y ago
ok no problem i will do my reaserach
Brody
Brody•2y ago
I wish you good luck!
bedo_khaled0
bedo_khaled0OP•2y ago
but latly my cloudflare DNS records don't need change right ?
Brody
Brody•2y ago
those look good to me
bedo_khaled0
bedo_khaled0OP•2y ago
Thank Brody for your help and time Thanks
Brody
Brody•2y ago
no problem, have a nice day!
bedo_khaled0
bedo_khaled0OP•2y ago
It worked ! took a long time to show the 400 bad request again which is solved by adding realotakus.com to allowed_hosts
Brody
Brody•2y ago
im glad to hear it, i knew you would solve it fast!
bedo_khaled0
bedo_khaled0OP•2y ago
Thanks to me, and really Thanks to you !
Brody
Brody•2y ago
joint effort 🙂 mostly you though
bedo_khaled0
bedo_khaled0OP•2y ago
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
Brody
Brody•2y ago
web dev hard
Want results from more Discord servers?
Add your server