proxy_protocol_port variable should store the PROXY_PORT rather than CLIENT_PORT

Janusz M janusz.m at
Sat May 13 19:11:13 UTC 2017

I'd expect to see the original request's port 80 or 443 in this variable
rather than relatively useless (IMHO) CLIENT_PORT which looks like 51501.

A typical use case for this change would look like the following:

1. nginx HTTP server is running behind Amazon Load Balancer in TCP mode
with PROXY PROTOCOL enabled (can be any TCP load balancer with proxy
protocol on, useful for websockets for example)
2. nginx has the proxy_protocol turned on
3. we (or other apps, upstream servers) want to know what was the ORIGINAL
port/protocol of the incoming request (eg. was it 80/HTTP or 443/HTTPS).

Currently it seems that it's impossible to get the request port/protocol
value from nginx behind tcp load balancer. If nginx stored the PROXY_PORT
instead of the CLIENT_PORT value in that (or another) variable it would be
extremely easy for other apps to know the original port/protocol.

server {
  listen 80 proxy_protocol;
  proxy_set_header X-Forwarded-Port  $proxy_protocol_port; # 51505 instead
of 443/80 !!

Please let me know if it's feasible or planned, or if we could actually
read the original incoming request port in a different way
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the nginx-devel mailing list