Forum: NGINX all request is redirected to one port if there is multiple listen in default server section

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6d4a6e9574c15d11480db6d7e5eb2750?d=identicon&s=25 Delta Yeh (Guest)
on 2009-04-10 04:34
(Received via mailing list)
I use the following config:

server {
                    listen 192.168.1.102:80;
                        listen 192.168.1.102:81;

        server_name  _;  #default
        return 444;
    }

#upstream cfg
        upstream web_upstream0 {
        server 192.168.39.100:81 max_fails=3  fail_timeout=30s;

    }
        upstream web_upstream1 {
        server 192.168.39.100 max_fails=3  fail_timeout=30s;

    }

server {
     listen 192.168.1.102:81;
    server_name www.test1.com;
     location / {

            proxy_pass http://web_upstream0/;
    }
}
server {
     listen 192.168.1.102:80;
    server_name www.test2.com;
     location / {

            proxy_pass http://web_upstream1/;
    }
}


It seems all request to  www.test1.com is passed to www.test2.com.


If I use:

server {
                    listen 192.168.1.102:80;

        server_name  _;  #default
        return 444;
    }
server {
                        listen 192.168.1.102:81;

        server_name  _;  #default
        return 444;
    }

instead, every thing is OK.
Is this a bug ?
5640e332954fc0006aea97a155ce0afd?d=identicon&s=25 Igor Sysoev (Guest)
on 2009-04-10 08:14
(Received via mailing list)
Attachment: patch.0.7.50 (3 KB)
On Fri, Apr 10, 2009 at 10:24:59AM +0800, Delta Yeh wrote:

> #upstream cfg
>      listen 192.168.1.102:81;
>
> server {
>     }
>
> instead, every thing is OK.
> Is this a bug ?

Yes, this is a bug, introduced in 0.7.39. The attached patch fixes it.
6d4a6e9574c15d11480db6d7e5eb2750?d=identicon&s=25 Delta Yeh (Guest)
on 2009-04-10 08:56
(Received via mailing list)
thanks for you quick fix.

2009/4/10 Igor Sysoev <is@rambler-co.ru>
This topic is locked and can not be replied to.