It might help to set up a default "catch all" server. There's more info on it here: <a href="http://wiki.nginx.org/NginxHttpCoreModule#server_name">http://wiki.nginx.org/NginxHttpCoreModule#server_name</a> and it's done differently depending on your version of nginx.<br>
<br>You can set up your default server to point to one of your sites, or you can use it to show a 404 for invalid domains.<br><br>I have a CMS that hosts multiple, unrelated sites, and after looking through my logs recently, I was finding that one of the sites (the one nginx determined as the "default") was receiving all sorts of garbage traffic from bots, script kiddies, and the like. Some of the requests were from old domains that were pointed at an IP I had recently acquired, some were targeted at the IP address itself with no Host header, and the majority were penetration testing (like <a href="http://some-made-up-domain.com/*">http://some-made-up-domain.com/*</a>).<br>
<br>Since I didn't want to send all this traffic to my CMS backend, I wanted to have nginx filter it upfront. As such, I now have the following as my "default" server:<br><br>server {<br> listen 80 default;<br>
server_name _;<br><br> root /var/www/default;<br> log_format nosy '$remote_addr - $remote_user [$time_local] '<br> '"$request" ["$scheme://$host$request_uri"] $status $body_bytes_sent '<br>
'"$http_referer" "$http_user_agent"';<br> access_log /var/log/nginx/default.access.log nosy;<br> error_log /var/log/nginx/default.error.log;<br><br> location / {<br>
return 404;<br> }<br>}<br><br>The lot_format is of course optional, but I wanted to add it since the default log format doesn't include $host (just $request_uri). Also, I wanted to monitor for traffic from old domains that are still pointed at my IP address. If you don't care about this, you can just use "access_log off;". It may be worth noting that since I set this up about a month ago, the default.error.log file is still empty.<br>
<br>Since the traffic is garbage, I don't care what the 404 page looks like, so the default one that nginx serves up is fine with me.<br><br><div class="gmail_quote">On Fri, Mar 13, 2009 at 2:47 PM, Chris Cortese <span dir="ltr"><<a href="mailto:cortese.consulting@gmail.com">cortese.consulting@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">I just figured out the problem.<br>
<br>
I did not include the "www" version of my domains in the .conf in some cases. I have fixed it.<br>
<br>
Still, I don't understand why the behavior should be defaulting to whatever site I happened to configure first.<div><div></div><div class="h5"><br>
<br>
<br>
Jim Ohlstein wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
This happened with me a short time ago on a new server.<br>
<br>
If your site config files include:<br>
<br>
listen domain.tld;<br>
<br>
try changing them to:<br>
<br>
listen 80; <br>
or<br>
<br>
listen *:80;<br>
<br>
or<br>
<br>
listen xx.xx.xx.xx:80;<br>
<br>
Jim<br>
<br>
------Original Message------<br>
From: Chris Cortese<br>
Sender: <a href="mailto:owner-nginx@sysoev.ru" target="_blank">owner-nginx@sysoev.ru</a><br>
To: nginx<br>
ReplyTo: <a href="mailto:nginx@sysoev.ru" target="_blank">nginx@sysoev.ru</a><br>
Subject: wrong site displayed--seemingly randomly<br>
Sent: Mar 13, 2009 3:25 PM<br>
<br>
I moved my sites over to a new server and a new install of nginx-0.7.40 a couple days ago. I noticed once 2 days ago that I went to one domain and one of my other sites showed up. I thought this must be something strange with the DNS propagation.<br>
<br>
Today my business partner went to our site and saw this same other site instead. The site that sometimes is mistakenly showing up is the first site I migrated to the new server setup.<br>
<br>
None of these sites is set to be any sort of default, and all are included an:<br>
include ...../sites-available/*.conf;<br>
<br>
Anybody have any idea what else could be causing this? It's a pretty serious problem.<br>
<br>
<br>
Thanks,<br>
Chris<br>
<br>
<br>
<br>
<br>
Sent from my Verizon Wireless BlackBerry<br>
</blockquote>
<br>
<br>
</div></div></blockquote></div><br>