Proxy an intranet, or another server’s content through a different webserver. Say you have an intranet (internal) server whose content you want exposed to the public internet without actually giving it a public IP. You can use the following rewrite rule on a public server to proxy requests to the private server.

Proxy Via HTTPS Protocol

Add the following rule to nginx.conf:

server {
    listen example.com:443;
    server_name  example.com;

    location / {
        root /path/to/another/public;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass https://another.com:8080;
    }

}

This would cause all requests to the public server to be proxied to the ‘another.com’ server using the HTTPS protocol. To proxy via HTTP simply modify the protocol and port number.