using a proxied server as default_server
Francis Daly
francis at daoine.org
Fri May 31 13:01:21 UTC 2013
On Fri, May 31, 2013 at 07:30:22AM -0400, angelochen960 wrote:
Hi there,
> Sorry for not making it more specific, the issue is, the app in the tomcat
> is a virtual host as well, so it checks 'host' field for 'sample.com',
No worries.
Now that you have identified the problem, the possibilities for solutions
are more obvious :-)
For example, as an alternative to what you have already working, you
could note that you have the following line in your config:
proxy_set_header Host $http_host;
which sends the Host: header to the backend with the value of the
$http_host variable, which is the content of the incoming Host: header
(and may be empty).
If your backend requires that this always be "sample.com", then you
could instead use
proxy_set_header Host sample.com;
or possibly something like $server_name that has the same value.
> default_server with specific IP when accessed by a IP address like
> http://192.168.1.1/, it will not have a 'host', thus when passed to the app
> in the tomcat, it will not hit the right virtual host there, initially I was
> thinking, probably nginx can insert the 'host' before proxy to tomcat to
> make it work.
Strictly, it might have no Host, or it might have a Host of
192.168.1.1. Either way, it is not what your tomcat expects (unless it
is *also* the default server for connections to this address).
And getting nginx to insert the Host header you want is one way to approach it.
Cheers,
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list