this question does not duplicate of this link
My application is web based and developed in django, deployed through UWSGI application server with nginx as a reverse proxy. The task is to redirect from https to http for a specific URL, but this sound does not simpler to me as I tried to cope up with following nginx configuration are as:
The default proxy config are as:
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-Proto $scheme;
The location block where Issue happened are as:
location ~ /target\.xml$ {
if ($scheme = https) {
return 302 http://$host$request_uri;
}
}
The url which we need to redirect are as:
**https://test-server.com/api/stage/7uibsiub3jbh3v3h/target.xml**
Here if a url contains target.xml and is on https scheme then it should be redirect to http but we were receiving redirect loop in block due to missing if condition in location. As soon as we added if condition to check the scheme the nginx gave us 404 Not Found
error. I had double cross check with nginx documentation which told me to not go for if condition as it could be evil most of the times so I stick with location but I am unable to debug it more.
Thanks in advance.