Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

The following was my deployed servers:

client ------ nginx proxy( ------ back-end server(

The nginx proxy's external URL was configured under a virtual directory The back-end server was configure to

the following was part of the nginx configure file:

    location /demo {
            proxy_redirect  default;
            proxy_set_header        Host            $http_host;
            proxy_set_header        X-Real-IP       $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;

When the back-end server send a redirect response (HTTP CODE 302) with LOCATION head field "", the nginx map this LOCATION header field to "", not the disired ""

share|improve this question

The backend app has to be aware of virtual hosting, like Zope virtual host monster and other solutions, basically it has to have a way to knowing that it is behind a virtual/proxied server and rewrite the internal URLs, rewrites and etc accordingly.

At least, the internal application has to write its rewrites and urls relative to the external path. In the example, the internal application is probably sending a redirect to /subdir instead of /demo/subdir.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.