Opened 5 years ago

Closed 5 years ago

#1754 closed enhancement (wontfix)

Proxy request supports different Host load balancing(http+https)

Reported by: f4nff@… Owned by:
Priority: minor Milestone:
Component: other Version: 1.15.x
Keywords: Proxy Cc:
uname -a:
nginx -V: 1.15.10

Description

upstream a.com {
      server  192.168.5.126:80;
      server  192.168.5.27:80;
}
 
server{
    listen 80;
    server_name a.com;
    location / {
        proxy_pass         http://a.com;
        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

This is the current use of load balancing.
But can't support multiple host names.

I have a suggestion to support host + ip.

upstream server {
     http 	server  192.168.5.126:80	Host	a.com;
      https server  192.168.5.27:443	Host	b.com;
}
 
server{
    listen 80;
    server_name a.com;
    location / {
        proxy_pass         server;
#        proxy_set_header   Host             $host;
        proxy_set_header   X-Real-IP        $remote_addr;
        proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
    }
}

Change History (1)

comment:1 by Maxim Dounin, 5 years ago

Resolution: wontfix
Status: newclosed

The "upstream" block is to control how a name as written in the proxy_pass directive is converted to an IP address - basically, a more sophisticated replacement of DNS - and it is not expected to change the request in any way. If you want to pass different requests to different servers for some reason, you may want to consider using different proxy_pass / proxy_set_header settings instead.

Note: See TracTickets for help on using tickets.