Nginx – How to proxy requests to an internal server using nginx

nginxPROXYreverse-proxy

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.

EDIT

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

 location /git {
        proxy_pass              http://192.168.1.111:3000/;
 }

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

Best Answer

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.