title: nginx and DNS subdomain, too many redirects
body: <p>I just installed nginx and set it to work over an apache installation. As a matter of fact, my rules are:</p>
  
  <pre><code>server {
      listen 80;
  
      server_name example.com;
  
     location / {
         proxy_set_header X-Readl-IP $remote_addr;
         proxy_set_header X-Forwarded-For $remote_addr;
         proxy_set_header Host $host;
         proxy_pass http://example.com:8080;
     }
  
     location ~ /\.ht {
         deny all;
     }
  }
  </code></pre>
  
  <p>and I wanted to configure a subdomain by:</p>
  
  <pre><code>server {
     listen 80;
     server_name sub.example.com;
  
      location / {
          proxy_pass http://example.com:8080/sub;
      }
  
      location ~/\.ht {
          deny all;
      }
  }
  </code></pre>
  
  <p>And configuring my DNS like so:</p>
  
  <pre><code>NAME     |     TYPE     |     TARGET
  //empty         A           45.23.67.89
   sub           CNAME        example.com
  </code></pre>
  
  <p>I waited for propagation, but i'm getting "too many redirects" in chrome...</p>
  
  <p>The response is always 301, and redirected to the IP:80, I'm guessing that this is caused because of the A line in DNS... howver domain.com does redirect to apache and I do get the "it works" we all know so well...</p>
  
  <p>Can anyone one point me to the right direction please?</p>
  
  <p>Thanks!</p>
  
  <p><strong>UPDATE</strong>:</p>
  
  <p>I added another subdowmain, sub-sub, following <strong>EXACTLY</strong> the same procedure, but it magically works... need help! </p>