登录

proxy_pass - client端http协议访问nginx,为何不能反向代理为https出nginx ?

我在nginx中配置了如下虚拟主机。
我访问http://127.0.0.1:8112/,按理说应该可以反向代理到https//www.baidu.com,因为校验服务端证书的话,应该是在proxy_pass时执行。

server {
    listen 8112;
    location / {
            proxy_pass https://test8112;
    }
}
upstream test81122 {
    server www.baidu.com;

}

但是,查看error.log日志,发现如下所示的错误:
2017/04/16 21:34:14 [error] 14031#0: *1 SSL_do_handshake() failed (SSL: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol) while SSL handshaking to upstream, client: 192.168.153.1, server: saas-portal.eastdc.cn, request: "GET / HTTP/1.1", upstream: "https://14.215.177.37:80/", host: "127.0.0.1:8112"

当我用https协议访问nginx时,能正常访问https://www.baidu.com
没看过nginx源码,求大神解惑。

# Linux
我想大声告诉你 我想大声告诉你 2490 天前 1631 次浏览

全部回复(1) 我要回复

  • 某草草

    某草草2017-06-24 09:46:30

    我又去测试了,亲测可以http接入nginx,https出nginx,如下是我的测试配置,可以访问到baidu首页。

    server {
        listen 8113;
        server_name saas-portal.test.cn;
        location / {
                proxy_set_header Host "www.baidu.com";
                proxy_pass https://test8113;
        }
    }
    upstream test8113 {
        server 115.239.211.112:443;#此ip为百度ip
    }

    回复
    0
  • 取消 回复 发送