代理服务器nginx A 通过域名代理到后端的服务器B,A是通过http1.1 长链接代理到B中,但是B的域名指向的ip会动态变化。
目前的配置如下:
http{
resolver xxx.xxx.xxx.xxx valid=30s;
server{
location = /xxxx/xxxx {
set $host "aaa.aaa.com";
proxy_pass http://$host/xxx/xxxxx;
keepalive_requests 1000;
keepalive_timeout 15s;
proxy_http_version 1.1;
proxy_set_header Connection "keep-alive";
proxy_connect_timeout 200;
proxy_send_timeout 200;
proxy_read_timeout 200;
}
}
}
以上配置的问题是,域名指向的动态ip 能够顺利切换。
也可以使用nginx的第三方模块 ngx_http_dynamic_upstream_module:https://github.com/zhaofeng0019/nginx-upstream-dynamic-resolve-servers/blob/master/README.cn.md
原文地址:https://groups.google.com/g/openresty/c/Eog9QKohTRE |