I configured the following virtual host in nginx.
When I visit http://127.0.0.1:8112/, it should be possible to reverse proxy to https//www.baidu.com, because the verification of the server certificate should be performed during proxy_pass.
server {
listen 8112;
location / {
proxy_pass https://test8112;
}
}
upstream test81122 {
server www.baidu.com;
}
However, checking the error.log log, I found the following error:
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"
When I use the https protocol to access nginx, I can access https://www.baidu.com normally.
I haven’t seen the nginx source code, please let me know.
某草草2017-06-24 09:46:30
I went to test again. I personally tested that I can connect to nginx via http and get out of nginx via https. The following is my test configuration, which allows me to access the Baidu homepage.
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
}