#Railway deploying django help wanted!
101 messages · Page 1 of 1 (latest)
Project ID: 86e751b8-5900-4d54-b224-51a403c96f46
86e751b8-5900-4d54-b224-51a403c96f46
well first, don't listen to Alex, delete your dockerfile, redoploy, then give me your full build log please
@random whale Hello Brody, here is the full log:
looks like you are trying to use a windows specific package, services on railway generally use ubuntu
actually, i just noticed pywin32
i deleted this from requirements.txt
yep that would be the package in question
let me see if that work now
you may have pip freezed every package on your system into the requirements.txt file, please go through that file and delete all packages you don't use in your project
no i only freezed the one inside the virtual environment of my project
ah cool
i guess that indicate the deployment suceeded?
more or less yeah
ok, so how do i figure out the CNAME on railway?
cause i am gonna point the domain from cloudflare to railway deployment
do you own a domain?
yes.
who's your domain provider
cloudflare
perfect
then go to the service settings, add your custom domain, then railway will give you the cname address, use that in the cloudflare DNS settings
make sure you have set SSL/TLS mode to full in cloudflare too
i can't see any cname address in the settings, the domain is already set
you would have been given the cname when you added the domain
send me your custom domain please, along with a screenshot of the domains in the railway service, and your DNS settings in cloudflare
nvm, got it when i re-added the domain
all works?
let me see one last thing
I guess that part of "DNS takes 72 hours to propgate"?
do you see that from your custom domain?
yes.
then DNS has already propagated, that's an issue with your app
alright, let me see then
any errors in the deploy logs
deployment logs
oh you definitely don't want to be running a development server on railway
oh snap
do you have a Procfile?
how did i not notice this, ok so, what the procedure here?
in the old times, i used to keep the server running using gunicorn+ niginx for load balancing
but I guess railway does handle the server running for me
ok, let's speak in term of gunicorn, why do i need it?
i thought gunicorn whole idea is to keep a server running, no?
@terse raven your expertise are required
(he's an extremely experienced python dev)
noice
Oi!
thanks for help Brody 🙂
Let me read and catch up
take your time
why gunicorn necessary
Thanks. I’m caught up. Gunicorn isn’t a process manager, it is a whole production WSGI server. If you just run your manage.py file, it will launch the dev server which is for testing, and as you can see is looking at the wrong port.
With Gunicorn, it will not display error logs on the front end when people hit one, exposing not only your file structure, but also exposing a debug terminal in the browser allowing people to run exploitation code
whats more so the "what" and not the "why"
do you mind explaining how gunicorn handle running the server? I thought gunicorn somehow run on a local port too?
dev, no problems with wanting to understand it, but regardless if you understand or not, you still need gunicorn
I would place a railway.json file in your project root and place the following contents in it
{
"$schema": "https://railway.app/railway.schema.json",
"build": {
"builder": "NIXPACKS"
},
"deploy": {
"startCommand": "python manage.py migrate && python manage.py collectstatic --noinput && gunicorn mysite.wsgi",
"restartPolicyType": "ON_FAILURE",
"restartPolicyMaxRetries": 10
}
}
You can also look at the template for how to configure your port
yeah, i will create the procfile and add the gunicorn command, but i really want to understand why i need it for the future
you need it to run your app in a production environment, its as simple as that
Thanks, i will look it up
true, but what kind of address does gunicorn run in this case?
like in dev mode, i run 127.0.0.1 which is the local host
gunicorn runs on 0.0.0.0 and environment variable PORT by default
gunicorn will listen on the PORT env variable
that true, but isnt that local address too?
or is 0.0.0.0 a different case?
It’s not a loop back address like 127.0.0.1
0.0.0.0 binds to all network interfaces in a server environment
all ipv4* hehe
just had a good read here:
https://www.howtogeek.com/225487/what-is-the-difference-between-127.0.0.1-and-0.0.0.0/
I guess 0.0.0.0 work as a placeholder address, which let all addresses access it
thats a good enough analogy
wtf is this embed tho 😭
Discord being dumb
i will re-deploy and give you a feedback!
why is $schema a not allowed property in json?
dont worry about that
was busy for a while, i re-deployed, now i get too many redirects error
Do you have your cloudflare ssl settings on “Full”
remember when i said this lol
let me check, but last time it was
If it’s anything other than “Full”, it will not work
No, don’t use strict
django may also be a culprit for too many redirects
And you used the cname address provided by railway when you added the domain?
100%
Not the railway generated domain as the target, correct?
yes
the one they gave me when i set my custom domain (it was a dialog box)
Yes, that’s the one you should be using. Unfortunately I’m not on the computer for another 4 1/2 hours, so I can’t really help troubleshoot too much more
all good fam, thanks for your help 🙂 !
Anytime
alright i fixed everything
i had set SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') in settings.py for django, which fixed the redirect error.
Thank you for marking this question as solved!
1123174381372313670
1123465795922579567
You’re good. It’s solved