proxy_pass & getServerPort problems
francis at daoine.org
Thu Feb 13 10:21:00 UTC 2014
On Thu, Feb 13, 2014 at 02:00:48AM +0100, Jiang Web wrote:
> Francis Daly wrote in post #1136476:
> > getServerPort is not an nginx thing, and nginx probably cannot affect
> > what it reports.
> > What do you do with the result of getServerPort?
> we get the last request url(in java
> program) using <%request.getRequestURL%>, but the result is
> xxxxxxxx=http://w3.huawei.com:9090/NetWeb not the
> http://w3.huawei.com/NetWeb. We test it and found that:
> <%request.getServerName%> is w3.huawei.com
> <%request.getServerPort%> is 9090
> <%request.getURI%> is /NetWeb
> so we think that when we use the nginx as a reverse proxy to proxy the
> request, the request.getServerPort is 9090 not 80. If we use the apache
> as a reverse proxy to proxy the request adding parameter
> "ProxyPreserveHost on", the request.getServerPort is 80.
The nginx equivalent to "ProxyPreserveHost on" is probably
"proxy_set_header Host $http_host". It might be worth trying that.
If that doesn't work, then perhaps tcpdump the traffic between apache
and the backend when it works, and between nginx and the backend when
it fails, and spot the difference.
The relevant question is probably: what does your java getServerPort
(or getRequestURL) do to find its answer? Once you know that, you can
see whether it is possible for nginx to influence it. (Since apache did
influence it, presumably nginx can too.)
Francis Daly francis at daoine.org
More information about the nginx