Proxy behind firewall where ports don't match

Igor Sysoev is at rambler-co.ru
Wed Jan 23 10:01:40 MSK 2008


On Tue, Jan 22, 2008 at 07:22:47PM -0600, Casey Rayman wrote:

> I've got a situation where the port being served to the outside world  
> and the proxy port may not be the same.  e.g. firewall:9000 => nginx: 
> 8080 => realserver:8000
> 
> I'm currently using the following line which seems to take care of  
> everything but the port:
> 	proxy_redirect  http://realserver:8000 https://$host:9000;
> 
> I'd like something like this:
> 	proxy_redirect  http://realserver:8000 https://$host:$port;
> 
> Where $host:$port turns into firewall:9000 for the above example.   
> I've found variables for both the nginx port and the realserver port,  
> but can't find anything for the port the client sent the request to.

There is no way to learn firewall's IP address and port on nginx side at all.

You may try

 	proxy_redirect  http://realserver:8000 https://$http_host;

this will work if client sends "Host: www.example.com:9000".


-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list