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;
}

命令行修改GoDaddy DNS脚本

#通过命令行快速修改GoDaddy域名DNS
[ ! $# -eq 3 ] && echo -en “Usage: <Domain> <Name> <IP>\n” && exit 3
#Example: ./changedns.sh xxxx.com www 1.2.3.4
# Get the Production API key/secret from https://developer.godaddy.com/keys/.
# Ensure it’s for “Production” as first time it’s created for “Test”.
Key=’YouKey’
Secret=’YouSecret’
Domain=$1
Type=A
Name=$2
TTL=600
CachedIP=$3
echo “DNSUpdate: ${Name}.${Domain}–> ${CachedIP}.”
Curl=$(/usr/bin/which curl 2>/dev/null)
Touch=$(/usr/bin/which touch 2>/dev/null)
[ “${Curl}” = “” ] &&
echo “Error: Unable to find ‘curl CLI’.” && exit 1
[ -z “${Key}” ] || [ -z “${Secret}” ] &&
echo “Error: Requires API ‘Key/Secret’ value.” && exit 1
[ -z “${Domain}” ] &&
echo “Error: Requires ‘Domain’ value.” && exit 1
[ -z “${Type}” ] && Type=A
[ -z “${Name}” ] && Name=@
[ -z “${TTL}” ] && TTL=600
[ “${TTL}” -lt 600 ] && TTL=600
#${Touch} ${CachedIP} 2>/dev/null
#[ $? -ne 0 ] && echo “Error: Can’t write to ${CachedIP}.” && exit 1
echo -en “changed!\nUpdating ‘${Domain}’…”
Update=$(${Curl} -kLsXPUT -H”Authorization: sso-key ${Key}:${Secret}” \
-H”Content-type: application/json” \
https://api.godaddy.com/v1/domains/${Domain}/records/${Type}/${Name} \
-d “[{\”data\”:\”${CachedIP}\”,\”ttl\”:${TTL}}]” 2>/dev/null)
if [ $? -eq 0 ] && [ “${Update}” = “” ];then
echo “Success!”
eval ${SuccessExec}
else
echo “Fail! ${Update}”
eval ${FailedExec}
exit 1
fi
exit $?