Welcome! Log In Create A New Profile

Advanced

Re: using a proxied server as default_server

Francis Daly
May 31, 2013 09:02AM
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@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

using a proxied server as default_server

angelochen960 May 30, 2013 10:16PM

Re: using a proxied server as default_server

Francis Daly May 31, 2013 04:10AM

Re: using a proxied server as default_server

angelochen960 May 31, 2013 07:30AM

Re: using a proxied server as default_server

Francis Daly May 31, 2013 09:02AM

Re: using a proxied server as default_server

angelochen960 May 31, 2013 10:06AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 267
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready