nginx load balancing problem based on domain name
黄舟
黄舟 2017-05-16 17:08:23
0
1
777

question

upstream ops {
    #ip_hash;
    server 5000.ali-bj.cloud.net:10080 weight=2 max_fails=1 fail_timeout=2;
    server 5000.ali-sh.cloud.net:10080 weight=1 max_fails=1 fail_timeout=2;
    #server 192.168.0.4:5000 max_fails=1 fail_timeout=2;
    #server 127.0.0.1:12309;
    #server 127.0.0.1:12310;
    #server 127.0.0.1:10080 ;
}
----
#web.conf主要配置
    location / {
        add_header Version v3.1.5.3;
        add_header Os QingDao.aliyun.Debian8;
        proxy_set_header         X-Via            QingDao.Aliyun;
        proxy_set_header         Connection       "";
        proxy_set_header         Host             $http_host;
        proxy_set_header         X-Real_IP        $remote_addr;
        proxy_set_header         X-Forwarded-For  $proxy_add_x_forwarded_for;
        proxy_pass http://ops;
        proxy_cache opscache;
        proxy_cache_valid 200 302 5m;
        proxy_cache_valid 301 1h;
        proxy_cache_valid any 1m;

    }

illustrate:

5000.ali-bj.cloud.net/5000.ali-sh.cloud.net 域名都是解析到同一个ip(192.168.1.124)上的

Access domain name 502:

2017/04/03 11:26:14 [error] 408#408: *1 upstream prematurely closed connection while reading response header from upstream, client: 192.168.1.105, server: dev.cloud.net, request: "GET / HTTP/1.1", upstream: "http://192.168.1.124:10080/", host: "dev.cloud.net"

doubt?

Can nginx upstream perform load balancing based on domain names? Host $http_host is still the same after setting it

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
给我你的怀抱

Obviously nginx supports virtual hosts! Then different virtual hosts can define different upstreams!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template