Hi,

May I ask for your opinion on the following case:

When RemoteIpValve is enabled getServerPort returns inconsistent value 
depending on the presence of protocolHeader (“x-forwarded-proto” by default)

Here is a short example
1) no x-forwarded-proto
curl -H "Host: myserverhost:32279" -H "x-forwarded-for: 10.0.0.10" 
http://10.19.82.245:8080/remoteip.jsp
getRemoteAddr 10.0.0.10
getRemoteHost 10.0.0.10
getServerPort 32279
getScheme     http

2) with x-forwarded-proto
curl -H "Host: myserverhost:32279" -H "x-forwarded-for: 10.0.0.10" -H 
"x-forwarded-proto: https" http://10.19.82.245:8080/remoteip.jsp
getRemoteAddr 10.0.0.10
getRemoteHost 10.0.0.10
getServerPort 443
getScheme     https

Hence when we have the presence of x-forwarded-proto we default to 443 
otherwise we respect the value in the Host header.
Looking in the source code of the RemoteIpValve when setPort is invoked if the 
protocolHeader is present and defaults to 443 if portHeader is not present as 
in the case above but should it be as in the case 1)

Best regards
Niki

Reply via email to