title: Nginx site configuration disabling 301 rewrite for another site
body: <p>I currently have two enabled site configurations in nginx, let us call them <code>old-site.example</code> and <code>new-site.example</code>. There is no other site configuration active.</p>
  
  <p><code>old-site.example</code> should 301-redirect to <code>new-site.example</code>. This currently works well as long as the <code>old-site.example</code> configuration is alone. After adding the <code>new-site.example</code> configuration file, it does not redirect anymore.</p>
  
  <p><code>oldsite.conf</code>:</p>
  
  <pre><code>server {
          listen 80;
          server_name *.old-site.example;
          rewrite_log on;
          location / {
                  return 301 http://www.new-site.example$request_uri;
          }
  
  }
  </code></pre>
  
  <p><code>newsite.conf</code>:</p>
  
  <pre><code>server {
      listen       80;
      server_name  www.new-site.example;
  
  charset utf-8;
  
      location / {
          #forward to application server
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_pass http://127.0.0.1:8080;
      }
  }
  </code></pre>
  
  <p>other configuration details:</p>
  
  <ul>
  <li>JBoss AS7 as application server running behind Nginx 1.5.1</li>
  </ul>