通过这样的配置,我可以重定向到 google.com
server {
listen 80;
proxy_ssl_server_name on;
rewrite_log on;
location / {
proxy_pass https://google.com;
}
}
但如果我添加上游而不是主机
upstream some-backend {
server google.com:443;
}
server {
listen 80;
proxy_ssl_server_name on;
rewrite_log on;
location / {
proxy_pass https://some-backend;
}
}
答案1
这是因为 fqdn。服务器上发送的是 ip 而不是 fqdn。您可以使用该配置修复它:
upstream google.com {
server 10.16.1.51:443;
}
...
proxy_pass https://google.com;
proxy_ssl_server_name on;
或者您可以在位置部分手动设置标题:
location / {
proxy_pass https://some-backend;
proxy_ssl_server_name on;
proxy_ssl_name google.com;
proxy_set_header Host google.com;
}