浏览 204
#sip负载-5060
upstream app_proxy_5060 {
#hash $remote_addr;
server 192.168.1.211:5060 fail_timeout=65s max_fails=1;
server 192.168.1.212:5060 backup;
}
#sip代理-5060
server {
error_log /var/log/nginx/5060_error.log info;
access_log /var/log/nginx/5060_access.log proxy;
listen 5060 udp reuseport;
proxy_connect_timeout 5s; # 与被代理服务器建立连接的超时时间为5s
proxy_timeout 65s; # 获取被代理服务器的响应最大超时时间为10s #当被代理的服务器返回错误或超时时,将未返回响应的客户端连接请求传递给upstream中的下一个服务器
proxy_next_upstream on;
proxy_next_upstream_tries 1; # 转发尝试请求最多3次
proxy_next_upstream_timeout 65s; # 总尝试超时时间为10s
proxy_socket_keepalive on; # 开启SO_KEEPALIVE选项进行心跳检测
#proxy_responses 1;
#health_check interval=20 passes=2 fails=2 udp;
#proxy_bind $remote_addr transparent;
proxy_pass app_proxy_5060;
}
各位专家好,我在测试上述配置时发现一个问题,如果我把 211网线拔掉,sip 信令请求即udp请求 还是一直往211上发送,不会切换到212上,这是为什么呢?如果能解答请联系我,有红包答谢
按点赞数排序
按时间排序
UDP是无状态的,NGINX无法像感知TCP三次握手那样监测UDP链路是否正常。
建议在upstream中配置主动健康检查,并探测机器的其他可用TCP端口或HTTP服务来实现server的加载或剔除
0
回答于2024-03-08 00:04
sticky模块只能在linux下吧,win下没有。tomcat好像有个session复制吧,或者可以用共享session。
没办法完全不受影响的,因为mirror是子请求,当子请求未结束时,主请求消耗的内存至少是无法释放的。你可以尝试在/mirror里,把超时时间大幅度调低,包括connect/read/send,再压下看看。