Forum: NGINX Variable for the real port of a proxy?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mark Reginald J. (Guest)
on 2008-10-27 16:00
(Received via mailing list)
Hi,

Is there any way to set a header that identifies the real
port of the proxy that's handing a request? That is, if I
have a round-robin proxy-set, a request forwarded to the
proxy at port 8000 will have the header "X-Real-Port: 8000".

I've tried both the $proxy_port and the $server_port
variables, but they're both 80.

Thanks.
Mark Reginald J. (Guest)
on 2008-10-29 07:33
(Received via mailing list)
Mark Reginald J. wrote:
> Hi,
>
> Is there any way to set a header that identifies the real
> port of the proxy that's handing a request? That is, if I
> have a round-robin proxy-set, a request forwarded to the
> proxy at port 8000 will have the header "X-Real-Port: 8000".
>
> I've tried both the $proxy_port and the $server_port
> variables, but they're both 80.

I've found out that if, in 0.6.32, you do:

     proxy_pass        http://localhost:8000;
     proxy_set_header  X-Proxy-Port $proxy_port;

You get 8000 in the HTTP_X_PROXY_PORT header.

However if you do:

     upstream p {
       server localhost:8000
     }

     proxy_pass        http://p;
     proxy_set_header  X-Proxy-Port $proxy_port;

You get 80 in the HTTP_X_PROXY_PORT header.

Is this expected, or does it require a fix?
If so, is it an easy fix for the main devs,
or do you want me to work up a patch?

Thanks.
This topic is locked and can not be replied to.