Answer the question
In order to leave comments, you need to log in
How to properly pass HTTP headers to Django?
The challenge was to deploy an application to the Django server that uses the REMOTE_USER header. Nginx inserts an authorized user there and passes it on to the Gunicorn WSGI server. And the latter already transfers to the application. Looking through the headers, I realized that some intermediate instance adds the "HTTP_" prefix. Therefore, I get "HTTP_REMOTE_USER". The question is who adds this prefix and how to remove it?
I set the variable with a directive in NGINX:
Gunicorn is configured according to the standard:
proxy_set_header REMOTE_USER $remote_user;
ExecStart=/var/www/portal/venv/bin/gunicorn \
--access-logfile /var/log/gunicorn/access.log \
--error-logfile /var/log/gunicorn/error.log \
--capture-output \
--log-level debug \
--workers 3 \
--bind unix:/run/gunicorn.sock \
portal.wsgi:application
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question