Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

I have setup a web server to view my repositories (a Gitalist instance) on http://localhost:3000 and I want to setup a proxy using nginx.

I want that the request is proxied to my repository view when receiving a URI like DOMAIN/git/.

My current nginx configuration has been declared as follows:

location /git {
    proxy_pass http://localhost:3000/;

The requests do get proxied to the server but none of the images/links or css can be resolved as they point to "http://localhost:3000/logo.png" for example.


If I proxy_pass to the actual server address it does work:

 location /git {
        proxy_pass    ;

But there should be a way of hiding the actual servers address while proxying.

share|improve this question
up vote 2 down vote accepted

In the case URIs are absolute, a solution could be using the Nginx HTTPSubModule or switching to Apache with its mod_proxy_html module. They are both able to modify the response received from backend servers and make some replacements.

share|improve this answer
Apache is a bad idea – deFreitas Jul 3 at 22:46

Try the solution presented in the nginx wiki:

the result, should be something like this.

location /git {
    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    ;
share|improve this answer

The paths are not being proxied properly. See this link:

share|improve this answer
I have read the article, and tried their proxy configuration but it isn't helping. – eliocs Mar 5 '12 at 15:25

If an application produces HTML with absolute paths to graphics/scripts/pages and browser requests it -- neither application nor browser know you are trying to hide the application under /git path, so the browser will try to load them by their absolute paths. The whole idea would work if Nginx could re-write HTML, but it cannot.

share|improve this answer

If you're generating absolute links using the Host header sent in the request, then you should set Nginx to set that to the original Host header value, by adding:

proxy_set_header Host $http_host;

to the location block.

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.