haproxy实现端口转发

2019-12-29 14:49 阅读 1,724 views 次 haproxy实现端口转发已关闭评论
  1. 需要先确认已经配置了内核参数:
  1. echo 'net.ipv4.ip_nonlocal_bind = 1'>>/etc/sysctl.conf
  2. echo 'net.ipv4.ip_forward = 1'>>/etc/sysctl.conf
  3. sysctl -p
  1. 安装haproxy
yum install haproxy -y

/usr/sbin/haproxy -f /etc/haproxy/haproxy.cfg

vi /etc/haproxy/haproxy.cfg

service haproxy reload

https://blog.csdn.net/genglei1022/article/details/83374188

defaults

        log     global

        mode    tcp

        option  httplog

        option  dontlognull

        timeout connect 5000

        timeout client  50000

        timeout server  50000

        errorfile 400 /etc/haproxy/errors/400.http

        errorfile 403 /etc/haproxy/errors/403.http

        errorfile 408 /etc/haproxy/errors/408.http

        errorfile 500 /etc/haproxy/errors/500.http

        errorfile 502 /etc/haproxy/errors/502.http

        errorfile 503 /etc/haproxy/errors/503.http

        errorfile 504 /etc/haproxy/errors/504.http

listen stats

        bind 0.0.0.0:1080 

        stats refresh 30s

        stats uri /stats

        stats realm Haproxy Manager

frontend www

    bind *:80

    mode tcp

    option forwardfor

    log global

    default_backend htmpool

backend htmpool

    mode tcp

    option redispatch

    option abortonclose

    balance roundrobin

    server  k8s-node-1  testcafe.xxxx.com:32410 check

版权声明:本文著作权归原作者所有,欢迎分享本文,谢谢支持!
转载请注明:haproxy实现端口转发 | 文档
分类:电脑技术 标签:

评论已关闭!