# Some question about server listen

**URL:** <https://www.ruby-forum.com/t/some-question-about-server-listen/166577>\
**Category:** NGINX\
**Created:** [April 27, 2009, 4:00pm UTC](https://www.ruby-forum.com/t/some-question-about-server-listen/166577 "2009-04-27T16:00:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhijianpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b3f665/32.png) [@zhijianpeng](https://www.ruby-forum.com/u/zhijianpeng)\
**Post date:** [April 27, 2009, 4:00pm UTC](https://www.ruby-forum.com/t/some-question-about-server-listen/166577/1 "2009-04-27T16:00:22Z")

</div>

========my nginx.conf===========  
server {

```
           listen 10.1.1.1:80;
           server_name www.test1.com;
           root /opt/test1;
   }

```

server {

```
           listen 80;
           server_name www.test2.com;
           root /opt/test2;
   }

```

========my nginx.conf===========  
I found that server [www.test2.com](http://www.test2.com) not listen on 10.1.1.1 ,but only  
listen on 127.0.0.1,why ?

Posted at Nginx Forum:

> **[some question about server listen](https://forum.nginx.org/read.php?2,1455,1455#msg-1455)**
>
> ========my nginx.conf=========== server { listen 10.1.1.1:80; server\_name www.test1.com; root /opt/test1; } server { listen

---

<div class="post-metadata">

**Author:** ![zhijianpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b3f665/32.png) [@zhijianpeng](https://www.ruby-forum.com/u/zhijianpeng)\
**Post date:** [April 27, 2009, 4:12pm UTC](https://www.ruby-forum.com/t/some-question-about-server-listen/166577/2 "2009-04-27T16:12:09Z")

</div>

On Mon, Apr 27, 2009 at 09:50:27AM -0400, zhijianpeng wrote:

> ```
> listen 80;
> server_name www.test2.com;
> root /opt/test2;
> }
> 
> ```
> 
> ========my nginx.conf===========  
> I found that server [www.test2.com](http://www.test2.com) not listen on 10.1.1.1 ,but only listen on 127.0.0.1,why ?

Probably, you mistook: in this case nginx listen on \*:80 only.

If you want to bind() to an address, then you should set  
listen 10.1.1.1:80 default bind;

---

<div class="post-metadata">

**Author:** ![zhijianpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b3f665/32.png) [@zhijianpeng](https://www.ruby-forum.com/u/zhijianpeng)\
**Post date:** [April 28, 2009, 9:28pm UTC](https://www.ruby-forum.com/t/some-question-about-server-listen/166577/3 "2009-04-28T21:28:40Z")

</div>

## Igor S. Wrote:

> > ```
> > root /opt/test1;
> > 
> > ```
> > 
> > ========my nginx.conf===========
> 
> –  
> Igor S.  
> [Igor Sysoev](http://sysoev.ru/en/)

Yes,I saw that nginx listen on 0.0.0.0:80  
but when I use :  
curl -v -H “Host: [www.test2.com](http://www.test2.com)” [http://10.1.1.1/index.html](http://10.1.1.1/index.html)  
I get the result of [www.test1.com/index.html](http://www.test1.com/index.html),

and use  
curl -v -H “Host: [www.test2.com](http://www.test2.com)” [http://127.0.0.1/index.html](http://127.0.0.1/index.html)  
then get the result of [test2.com&nbsp;-&nbsp;test2 Resources and Information.](http://www.test2.com/index.html)

In this case ,does “listen \*:80” means this virtual\_server only bind  
to the ip address not used by any other virtual\_server?

Posted at Nginx Forum:

> **[Re: some question about server listen](https://forum.nginx.org/read.php?2,1455,1475#msg-1475)**
>
> ========my nginx.conf=========== server { listen 10.1.1.1:80; server\_name www.test1.com; root /opt/test1; } server { listen

---

<div class="post-metadata">

**Author:** ![zhijianpeng](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/b3f665/32.png) [@zhijianpeng](https://www.ruby-forum.com/u/zhijianpeng)\
**Post date:** [April 28, 2009, 11:49pm UTC](https://www.ruby-forum.com/t/some-question-about-server-listen/166577/4 "2009-04-28T23:49:15Z")

</div>

On Mon, Apr 27, 2009 at 10:14:41PM -0400, zhijianpeng wrote:

> > > ```
> > > server_name            
> > > }
> > > 
> > > ```
> > 
> > ```
> > listen 10.1.1.1:80 default bind;
> > 
> > ```
> 
> and use  
> curl -v -H “Host: [www.test2.com](http://www.test2.com)” [http://127.0.0.1/index.html](http://127.0.0.1/index.html)  
> then get the result of [test2.com&nbsp;-&nbsp;test2 Resources and Information.](http://www.test2.com/index.html)
> 
> In this case ,does “listen \*:80” means this virtual\_server only bind to the ip address not used by any other virtual\_server?

Although nginx listen on \*:80, nevertheless it tests an address where  
a request was sent to, as if nginx was bind() to the address. It  
emulates  
usual socket bind() behaviour.
