title: Nginx "ERR_TOO_MANY_REDIRECTS" when redirecting http-to-https + reverse proxy
body: <p>I've configured nginx to forward HTTP to HTTPS. This works for everything except my reverse proxy websites (that are also configured in nginx).  I am getting the error <code>ERR_TOO_MANY_REDIRECTS</code> in my web browser for reverse proxy sites.  I'm not sure what I'm doing wrong.</p>
  <p>Below, is the configuration I'm using in <code>nginx.conf</code>:</p>
  <pre class="lang-none prettyprint-override"><code>server {
      listen       80;
      server_name  localhost;
      return 301 https://$host$request_uri;
  
      location / {
          root   &quot;C:\inetpub\wwwroot&quot;;
          index  index.html index.htm;
      }
  
      location /files {
          proxy_pass          http://localhost:89;
          proxy_http_version  1.1;
          proxy_set_header    Upgrade $http_upgrade;
          proxy_set_header    Connection keep-alive;
          proxy_set_header    Host $host;
          proxy_cache_bypass  $http_upgrade;
          proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header    X-Forwarded-Proto $scheme;
      }
  
      location /photos {
          proxy_pass          http://localhost:89/photos/;
          proxy_http_version  1.1;
          proxy_set_header    Upgrade $http_upgrade;
          proxy_set_header    Connection keep-alive;
          proxy_set_header    Host $host;
          proxy_cache_bypass  $http_upgrade;
          proxy_set_header    X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header    X-Forwarded-Proto $scheme;
      }
  
  }
  </code></pre>