title: infinite redirect loop with SSL
body: <p>I have a wordpress site on apache behind nginx proxy.
  I've configured SSL and now I can't preview draft posts, they end up in an infinite redirect loop to the same url.</p>
  
  <p>In our wp-config we have:</p>
  
  <pre><code> define( 'FORCE_SSL_LOGIN', true );
   define( 'FORCE_SSL_ADMIN', true );
   if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &amp;&amp; $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
      $_SERVER['HTTPS'] = 'on';
  </code></pre>
  
  <p>We have .htaccess for the apache root:</p>
  
  <pre><code>RewriteEngine on 
  
  RewriteCond %{REQUEST_URI} !^/Site/ 
  RewriteCond %{REQUEST_URI} !^/phpMyAdmin/ 
  RewriteRule ^(.*)$ /Site/$1 
  
  RewriteCond %{REQUEST_URI} !^/phpMyAdmin/ 
  RewriteRule ^(/)?$ /Site/index.php [L]
  </code></pre>
  
  <p>We have .htaccess for the Site folder:</p>
  
  <pre><code>RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.php$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]
  </code></pre>
  
  <p>If I access the post preview in http it works:
  <a href="http://my.domain/?post_type=portfolio&amp;p=3405&amp;preview=true" rel="nofollow">http://my.domain/?post_type=portfolio&amp;p=3405&amp;preview=true</a></p>
  
  <p>But with https it gets redirected (301) to the same url over and over again:
  <a href="https://my.domain/?post_type=portfolio&amp;p=3405&amp;preview=true" rel="nofollow">https://my.domain/?post_type=portfolio&amp;p=3405&amp;preview=true</a></p>
  
  <p>I've added an output buffer in the wordpress index.php, so I can see in the log that when accessing the secured link, it generates the post preview html, so the redirection must have occurred on the way back, after the php engine generated the post preview. </p>
  
  <p>For the secured link, in the apache access log I see, so I don't think the nginx is causing the problem:</p>
  
  <p>"GET /?post_type=portfolio&amp;p=3405&amp;preview=true HTTP/1.0" 301</p>
  
  <p>We use permalinks, and so published posts are previewed without any problem in both http and https.
  Any ideas?</p>
  
  <p>Thanks,
  Lior</p>