using a proxied server as default_server

Francis Daly francis at
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 '',

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 "", then you
could instead use

  proxy_set_header Host;

or possibly something like $server_name that has the same value.

> default_server with specific IP when accessed by a IP address like
>, 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 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.


Francis Daly        francis at

More information about the nginx mailing list