title: nginx proxy_pass to https / image-server not working
body: <p>I'm trying to proxy an image server imagekit.io so that all requests have same domain name. </p>
  
  <p>Have tried multiple configurations in HTTPS nginx server (with self-signed certificate) and even in HTTP server.</p>
  
  <p>Let's say the URL is <a href="https://ik.imagekit.io/hj8sm3kk7/brochures/92/1579/suzuki-gsx-r150-615123.pdf" rel="nofollow noreferrer">https://ik.imagekit.io/hj8sm3kk7/brochures/92/1579/suzuki-gsx-r150-615123.pdf</a></p>
  
  <p>With the below configuration, I'm trying to hit <a href="http://localhost.com:8800/brochures/92/1579/suzuki-gsx-r150-615123.pdf" rel="nofollow noreferrer">http://localhost.com:8800/brochures/92/1579/suzuki-gsx-r150-615123.pdf</a></p>
  
  <pre><code>server {
          listen       8800;
          server_name  localhost.com;
  
          location /brochures {   
              proxy_ignore_headers Set-Cookie;
             proxy_set_header Host ik.imagekit.io;                       
             # proxy_set_header X-Real-IP $remote_addr;
             # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
             proxy_set_header Pragma no-cache;
             proxy_set_header Accept $http_accept;
             proxy_set_header User-Agent $http_user_agent;
              proxy_set_header Accept-Encoding $http_accept_encoding;
              proxy_set_header Accept-Language $http_accept_language;
              proxy_set_header sec-fetch-mode navigate;
              proxy_set_header sec-fetch-site cross-site;
              proxy_set_header sec-fetch-user ?1;
              proxy_set_header :authority ik.imagekit.io;
              proxy_set_header :method GET;
              proxy_set_header :path $path;
              proxy_set_header :scheme https;
              proxy_set_header Upgrade-Insecure-Requests 1;
  
             proxy_pass https://ik.imagekit.io/hj8sm3kk7/brochures;
          }
  }
  </code></pre>
  
  <p>This however works:</p>
  
  <p><a href="http://localhost.com:8800/financial-advisor/mfs-investment-management-review" rel="nofollow noreferrer">http://localhost.com:8800/financial-advisor/mfs-investment-management-review</a> opens the same page as <a href="https://smartasset.com/financial-advisor/mfs-investment-management-review" rel="nofollow noreferrer">https://smartasset.com/financial-advisor/mfs-investment-management-review</a></p>
  
  <pre><code>location /financial-advisor {                        
             proxy_ignore_headers Set-Cookie;
             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 https://smartasset.com;
         }
  </code></pre>