1.conf
server {
listen 7070;
server_name localhost;
location / {
proxy_redirect off;
proxy_pass https://baidu;
}
}
upstream baidu {
server www.baidu.com;
}
2.conf
server {
listen 7070;
server_name localhost;
location / {
proxy_redirect off;
proxy_pass https://www.baidu.com;
}
}
为什么2.conf可以工作,但是1.conf无法将代理传递给https://baidu.com?
它收到502 Bad Gateway
个错误
答案 0 :(得分:0)
如果使用SSL,则必须在上游指令中将端口443添加到服务器: https://docs.nginx.com/nginx/admin-guide/security-controls/securing-http-traffic-upstream/
server {
listen 7070;
server_name localhost;
location / {
proxy_redirect off;
proxy_pass https://baidu;
}
}
upstream baidu {
server www.baidu.com:443;
}