<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On 12 February 2013 23:06, Igor Sysoev <span dir="ltr"><<a href="mailto:igor@sysoev.ru" target="_blank">igor@sysoev.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">On Feb 12, 2013, at 21:10 , ivan babrou wrote:<br>
<br>
> Hi, I have a question. It's better to describe with example<br>
><br>
> I point one.local and two.local to 127.0.0.1 and create following servers in config for nginx:<br>
><br>
> server {<br>
> listen 80;<br>
> server_name one.local;<br>
><br>
> location / {<br>
> return 404;<br>
> }<br>
> }<br>
><br>
> server {<br>
> listen two.local:80;<br>
> server_name two.local;<br>
><br>
> location / {<br>
> return 403;<br>
> }<br>
> }<br>
><br>
> If I request one.local then 403 is returned. If i change listen for one.local to one.local:80 then 404 correctly returned, but only after restart, reload doesn't help (that's probably bug too).<br>
<br>
</div>Is there in error_log error something like "listen(<a href="http://127.0.0.1:80" target="_blank">127.0.0.1:80</a>) failed (98: Address already in use)" ?<br></blockquote><div><br></div><div style>No, there's no such thing.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im">
> I expect to get 404 if i request one.local even if I listen on all addresses. Am I right?<br>
<br>
<br>
</div>No. Your first configuration is<br>
<br>
server {<br>
listen *:80;<br>
server_name one.local;<br>
}<br>
<br>
server {<br>
listen <a href="http://127.0.0.1:80" target="_blank">127.0.0.1:80</a>;<br>
server_name two.local;<br>
}<br>
<br>
A client connects to <a href="http://127.0.0.1:80" target="_blank">127.0.0.1:80</a>, so nginx uses the second server to processes request.<br>
When you change listen in the first server to <a href="http://127.0.0.1:80" target="_blank">127.0.0.1:80</a>, nginx has two servers for this<br>
listen port and chooses server using "Host" header.<br></blockquote><div><br></div><div style>This is what netstat says:</div><div style><br></div><div style><div>callisto ~ # netstat -ntl </div><div>Active Internet connections (only servers)</div>
<div>Proto Recv-Q Send-Q Local Address Foreign Address State </div><div>tcp 0 0 <a href="http://127.0.0.1:21213">127.0.0.1:21213</a> 0.0.0.0:* LISTEN </div><div>
tcp 0 0 <a href="http://0.0.0.0:80">0.0.0.0:80</a> 0.0.0.0:* LISTEN </div><div>tcp 0 0 <a href="http://0.0.0.0:22">0.0.0.0:22</a> 0.0.0.0:* LISTEN </div>
<div>tcp 0 0 <a href="http://0.0.0.0:5432">0.0.0.0:5432</a> 0.0.0.0:* LISTEN </div><div>tcp6 0 0 ::1:21213 :::* LISTEN </div><div>tcp6 0 0 :::22 :::* LISTEN </div>
<div>tcp6 0 0 :::5432 :::* LISTEN</div><div><br></div><div style>Here I only see <a href="http://0.0.0.0:80">0.0.0.0:80</a> and <a href="http://127.0.0.1:80">127.0.0.1:80</a> looks like a subset for this. So why can't nginx use the same socket?</div>
</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
--<br>
Igor Sysoev<br>
<a href="http://nginx.com/support.html" target="_blank">http://nginx.com/support.html</a><br>
<br>
_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br>Regards, Ian Babrou<br><a href="http://bobrik.name" target="_blank">http://bobrik.name</a> <a href="http://twitter.com/ibobrik" target="_blank">http://twitter.com/ibobrik</a> skype:i.babrou
</div></div>