Nginx 代理 https 到 http - routines:ssl3_get_record:wrong 版本号

Nginx proxy https to http - routines:ssl3_get_record:wrong version number

这就是我配置 Nginx 的方式

upstream stage {
   server example.com;
}
server {
    server_name IP;
    listen 80;
    
    location / {
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $host;
      proxy_set_header protocol Token;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection "Upgrade";
              
      proxy_pass https://stage; 
   }
}

我在 error.log

上看到了这个
2021/11/03 15:26:14 [error] 40782#40782: *1 SSL_do_handshake() failed (SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number) while SSL hands
haking to upstream, client: IP, server: IP, request: "POST / HTTP/1.1", upstream: "https://IP:80/", host: "IP:10784"

如何将用户的请求从 http 代理到 https?

最终配置:

upstream stage {
    server example.com:443;
}
server {
    server_name IP;
    listen 80;
    
    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host example.com;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-Port 443;
        proxy_set_header X-Forwarded-Proto: https;
        proxy_ssl_verify off;
              
        proxy_pass https://stage$request_uri; 
    }
}