Retrieving Django database sessions work locally behind a proxy but fail on Railway?
Does anyone know if or why reading Django (DRF) sessions might fail behind a reverse proxy on Railway such as Caddy or Nginx but work locally? I am using
django.contrib.sessions.backends.db
in my case.37 Replies
Project ID:
N/A
N/A
are you having gunicorn trust the proxy headers?
I will be honest, I don't think I have done that. Do you know where I can find documentation for this?
https://docs.gunicorn.org/en/stable/settings.html?highlight=forwarded-allow-ips#forwarded-allow-ips
add the flag
--forwarded-allow-ips *
to your gunicorn start commandThanks! I will try that out and see if it works
So when I run this I get an error:
I seen online that it may have something to do with the
wsgi.py
file but I am not quite sure. Here is my wsgi.py
file:
what's your start command
and where are you defining that start command
Oh that is in a
set_up.sh
file that is run by a Dockerfiledo you need to talk to your django app over the private network?
That will be the endgame plan
use this then -
side note, always best to use the standard names for environment variables such as
PORT
, then since you will need a fixed port simply define PORT
as a service variableAhh thanks for the information. I will reploy now
Unfortunately I get the same error:
I must be doing something wrong:
do you have the start command set elsewhere, like in the service settings?
Sorry, where would I find the service settings? I am not using a procfile or a gunicorn config file
you can find the settings tab after opening your service
Oh you mean in railway
Actually it fails locally also
And there is no additional start command in my railway settings
share your dockerfile?
And
set_up.sh
:
no railway.json either?
No sir
is
django_project
the correct folder name?Maybe it is how my project structure is structured?
share your repo?
Here is my repository structure:
quite hard to get a good grasp of what's going on like that, if sharing a link to your repo not a option, could you add me to it?
Unfortunately I had signed an NDA so it is not possible at the moment. But if you would like to look at a specific file I can do my best to provide it
ah okay no worries
I'm kinda out of ideas tbh
you said running the same set_up.sh locally gives you the same error?
That is correct
are you running that script while in the same folder that the script resides in?
This is also correct
back to having no ideas
Ah okay I fixed it. It was actually a syntax error where I did not put
"*"
in:
Basically it was a stringwhat a fun little bug
it did give an example, yet i gave you the wrong start command, my bad
No problem! I am going to figure out why the Django application is not using the
django_session
table