title: nginx appears to use rewrite regardless of server_name
body: <p>I have the following config file.</p>
  
  <pre><code>server {
    listen 80;
    server_name web.example.com;
  
    access_log  /var/www/example/shared/log/web.access.log;
    error_log  /var/www/example/shared/log/web.error.log debug;
  
    rewrite ^/(.*)$ http://www.example.net$request_uri; permanent;
  }
  </code></pre>
  
  <p>When I make a request for curl -Ii -H "Host: example.com" <a href="http://example.com" rel="nofollow">http://example.com</a> the above rewrite rule works. (ARGH).. </p>
  
  <p>The server_name explicitly says "web.example.com"</p>
  
  <p>2014/11/18 22:49:20 [notice] 30694#0: <em>1868 "^/(.</em>)$" matches "/", client: 1.2.3.4, server: web.example.com, request: "HEAD / HTTP/1.1", host: "example.com"
  2014/11/18 22:49:20 [notice] 30694#0: *1868 rewritten redirect: "<a href="http://www.example.net/" rel="nofollow">http://www.example.net/</a>", client: 1.2.3.4, server: web.example.com, request: "HEAD / HTTP/1.1", host: "example.com"</p>
  
  <p>Not present here is the other server { } configs.  Xavier (below) pointed out that I had set default_server for listen: 443; but not for listen: 80.  (argh)</p>