title: nginx reverse proxy redirects to http instead of https
body: <p>Having the following setup: NGINX (Port 443) &gt; Jetty (Port 9090) &gt; Spring Controller</p>
  <p>For simplifying the problem I use the following files:</p>
  <ul>
  <li>/main.html containing an iframe calling the spring controller <strong>/test</strong></li>
  <li>spring controller <strong>/test</strong> doing <code>return &quot;redirect:/iframe.html&quot;;</code></li>
  <li>/iframe.html with simple text saying &quot;This is IFrame&quot;</li>
  </ul>
  <p>With HTTP there is no problem but after switching the NGINX configuration to HTTPS I get the following error in the browser and the iframe is not displayed:</p>
  <blockquote>
  <p>main.html:7 Mixed Content: The page at 'https://dev/main.html'
  was loaded over HTTPS, but requested an insecure frame
  'http://dev/iframe.html'. This request has been blocked; the
  content must be served over HTTPS.</p>
  </blockquote>
  <p>So the controller redirects to http instead of https, this is my NGINX configuration which from my understanding should let the jetty/controller know that it is running on https:</p>
  <pre><code> server {
      listen 443      ssl http2;
      listen [::]:443 ssl http2;
      server_name dev;
  
      ssl on;
      ssl_certificate ...;
      ssl_certificate_key ...;
  
      location / {
          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_set_header X-Forwarded-Proto $scheme;
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-Port $server_port;
          
          proxy_ssl_name $host;
          proxy_ssl_server_name on;
  
          proxy_pass http://127.0.0.1:9090;
      }
  }
  </code></pre>