Welcome! Log In Create A New Profile

Advanced

Django proxy_pass redirect issues

Posted by littlevk 
littlevk
Django proxy_pass redirect issues
September 07, 2018 01:00PM
Hello,
I faced an issue with nginx proxy_pass to a Django app.

I configured nginx server to this django:

#######
server {
listen 443 ssl;
server_name mydjango.com;

ssl on;
ssl_certificate /opt/ssl/nginx/mydjango.crt;
ssl_certificate_key /opt/ssl/nginx/mydjango.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;

client_max_body_size 120M;

#charset koi8-r;
access_log /var/log/nginx/backend.mydjango.app.log main;
error_log /var/log/nginx/backend.mydjango.app.error.log error;

location / {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend.mydjango.app:3080/;
proxy_redirect off;
}
}
#######

But connecting to NginX reverse proxy (https://mydjango.com) django starts
redirecting and finish with a bad request changing in my browser to:
http://127.0.0.1:5002

It seems I forgot some proxy header but I tried some combinations and I dont
find the good one.


Thanks in advance,

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,281123,281123#msg-281123

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login