侧边栏壁纸
  • 累计撰写 38 篇文章
  • 累计创建 81 个标签
  • 累计收到 1 条评论

目 录CONTENT

文章目录

Nginx的KeepAlive配置

小李同学
2023-04-19 / 0 评论 / 0 点赞 / 641 阅读 / 196 字 / 正在检测是否收录...

原文:https://blog.sina.com.cn/s/blog_e59371cc0102ux5w.html

1.lvs作为负载均衡的一层代理,不合适的链接保持和断开,会对正常的业务造成影响;
2.TCP KeepAlive和HTTP的Keep-Alive不是同一回事情(这里注意http的keepalive中间有横杠)
3.KeepAlive需要在nginx中单独设置,系统内核没有全局配置

tcp设置keepalive

upstream mariadb_3306 {
    hash $remote_addr consistent;
    server 192.168.31.16:3306 weight=5 max_fails=3 fail_timeout=30s;
}

server {
    listen 3306 so_keepalive=on;
    proxy_connect_timeout 5s; # 连接超时时间
    proxy_timeout 1d; # 超时时间
    proxy_pass mariadb_3306; # 转发目标的IP及端口号
}

server {
    listen 3306 udp;
    proxy_connect_timeout 5s; # 连接超时时间
    proxy_timeout 1d; # 超时时间
    proxy_pass mariadb_3306; # 转发目标的IP及端口号
}
0

评论区