But I'm not defining an ip server_name. Isn't nginx listening for server_names?<br><br>Right now I have <a href="http://example.com">example.com</a> rewriting to <a href="http://www.example.com">www.example.com</a> They both listen on 10.1.2.3. Previously, I could connect to 10.1.2.3 and it would redirect me to the web server. Now when I connect to 10.1.2.3 it rewrites the url to <a href="http://www.example.com">www.example.com</a> and because I'm internal, that never resolves. How do I set nginx to do the redirect without the rewrite?<br>
<br><div class="gmail_quote">On Thu, Feb 9, 2012 at 6:34 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello!<br>
<div class="im"><br>
On Thu, Feb 09, 2012 at 01:06:14PM -0500, Bai Shen wrote:<br>
<br>
> They do.<br>
><br>
> However, I do have some weird behaviour. I have the server_name set to<br>
> <a href="http://www.example.com" target="_blank">www.example.com</a> and that correctly connects me to my web server. But if I<br>
> type in 10.1.2.3, that connects me to my web server as well, even though I<br>
> don't have a default rule setup.<br>
><br>
> When I go to 10.1.2.4 I get a "Welcome to nginx!" page.<br>
<br>
</div>When selecting server{} based on server_name nginx will look only<br>
through server{} blocks which have the listen socket defined.<br>
<br>
That is, if you have<br>
<br>
server {<br>
listen 80;<br>
server_name default;<br>
}<br>
<br>
server {<br>
listen <a href="http://10.1.2.3:80" target="_blank">10.1.2.3:80</a>;<br>
server_name <a href="http://example.com" target="_blank">example.com</a>;<br>
}<br>
<br>
nginx will never consider "default" server if connection comes to<br>
<a href="http://10.1.2.3:80" target="_blank">10.1.2.3:80</a>. All requests to <a href="http://10.1.2.3:80" target="_blank">10.1.2.3:80</a> will end up in<br>
"<a href="http://example.com" target="_blank">example.com</a>" server as it's the only server defined for the<br>
listen socket in question.<br>
<br>
More details may be found here:<br>
<br>
<a href="http://nginx.org/en/docs/http/request_processing.html#mixed_name_ip_based_servers" target="_blank">http://nginx.org/en/docs/http/request_processing.html#mixed_name_ip_based_servers</a><br>
<br>
and in docs.<br>
<div class="HOEnZb"><div class="h5"><br>
Maxim Dounin<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</div></div></blockquote></div><br>