首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HAProxy多端口映射-将请求转发到与相同后端服务器上的传入请求相同的端口

HAProxy多端口映射-将请求转发到与相同后端服务器上的传入请求相同的端口
EN

Stack Overflow用户
提问于 2019-09-14 02:15:09
回答 1查看 2.2K关注 0票数 1

我对haproxy的设置还很陌生。我能够成功地设置将前端请求路由到后端的特定端口。但现在我收到一个请求,要求将请求路由到相同的服务器但不同的端口。请求需要路由到的后端端口与传入端口相同。我在许多选项中尝试了下面的config,但似乎都不起作用

代码语言:javascript
复制
global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    timeout connect         10s
    timeout client          1m
    timeout server          1m

frontend  haproxynode_https
    bind 0.0.0.0:6443
    bind 0.0.0.0:10111
    bind 0.0.0.0:10121
    bind 0.0.0.0:10131
    bind 0.0.0.0:10141
    bind 0.0.0.0:10181
    bind 0.0.0.0:10191
    bind 0.0.0.0:10011
    bind 0.0.0.0:10021
    bind 0.0.0.0:10041
    bind 0.0.0.0:10051
    bind 0.0.0.0:10061
    bind 0.0.0.0:10071
    bind 0.0.0.0:10091
    bind 0.0.0.0:10241
    mode tcp     
    option tcplog
    timeout client 1h
    default_backend backendnodes_https

backend backendnodes_https
    mode tcp
    timeout server 1h
    option tcplog
    option tcp-check
    balance roundrobin
    default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100    
    server master XX.XXX.XX.XX weight 1 port 80 maxconn 512 check
    server master-1 XX.XXX.XX.XXX weight 1 port 80 maxconn 512 check
    server master-2 XX.XXX.XX.XX weight 1 port 80 maxconn 512 check

任何指针都是非常感谢的。

EN

回答 1

Stack Overflow用户

发布于 2019-09-15 05:07:16

先运行

haproxy -f /etc/haproxy/haproxy.cfg -c

conf文件一切正常吗?

在末尾添加:

代码语言:javascript
复制
  listen stats
  bind  :20000
  mode  http
  stats enable
  stats uri /stats
  stats hide-version
  stats refresh 60
  stats realm Haproxy-Statistics
  stats auth admin:password
  stats admin if TRUE

查看统计信息页面:使用浏览器连接

http://ip:20000/stats

请发送更多信息

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57928531

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档