[Fixed]-Nginx url redirect to custom url

1👍

Use proxy_redirect off:

location /bbb/ {
   proxy_pass 2.2.2.2:8000;
   proxy_redirect off;
}

proxy_redirect off tells nginx that, if the backend returns an HTTP redirect, it should leave it as is. (By default, nginx assumes the backend is stupid and tries to be smart; if the backend returns an HTTP redirect that says “redirect to http://localhost:8000/somewhere“, nginx replaces it with something similar to “http://yourowndomain.com/somewhere“, or, in your case, “http://yourowndomain.com:8090/somewhere“. Django is smart enough so there is no need for nginx to do such things.)

Leave a comment