Welcome! Log In Create A New Profile

Advanced

Re: Distinct upstream servers by name

Maxim Dounin
January 13, 2011 08:50AM
Hello!

On Wed, Jan 12, 2011 at 04:26:54PM -0500, hydrow wrote:

> Hello.
>
> I want to proxy 2 apache vhosts.
> Both vhosts running on apache default port: 8080 and both are resolved
> through /etc/hosts
>
> upstream ultimabex_upstream{
> server ultimabex.va:8080;
> server ultimabex.vb:8080;
> }
>
> The issue is how to send correct Host header to apache so it will find
> vhost in his vhosts.conf
> and serve it accordingly.
>
> Used custom LogFormat in apache to catch ServerName(%v),
> Canonical ServerName(%V) ans Host(%h) headers sent by nginx.
> Setting Host in nginx is altering Canonical ServerName(%V) in apache
> headers.
>
> tried:
> proxy_set_header Host $upstream_http_host - resulting in 127.0.0.1 in
> apache logs
> proxy_set_header Host $upstream_http_hostname - resulting in first
> found apache vhost
>
> It works great when i set Host manually, like:
> proxy_set_header Host "ultimabex.va"
> or
> proxy_set_header Host "ultimabex.vb"
>
> Any way to set it automatically?

No. The same upstream request is used to communicate with all
backend servers (including fallback via proxy_next_upstream to
another server if one backends dies), so the Host header can't be
different for different backend servers.

You have to configure identical ServerName's on all backends (or
add ServerAlias) and use that name in proxy_set_header.

Maxim Dounin

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

Distinct upstream servers by name

hydrow January 12, 2011 04:26PM

Re: Distinct upstream servers by name

Maxim Dounin January 13, 2011 08:50AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 253
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