NGINX 反向代理(填坑一)

server {
server_name *.xxx.com;
if ($http_host ~* “^(.*?)\.xxx\.com$”) { 
set $domain $1; 
}
location / {
proxy_pass https://$domain.google.com;
}
#proxy_pass里面有参数,NGINX会返回502错误
#改为如下即可
server {
server_name *.xxx.com;
resolver ns1.yourdns.com 8.8.8.8 valid=300s; #增加DNS解析
if ($http_host ~* “^(.*?)\.xxx\.com$”) { 
set $domain $1; 
}
location / {
proxy_pass https://$domain.google.com;
}