大网数据广告活动
服务器运维问答

How to secure HAProxy TCP stats socket? Needed for remote operation

· 52CE 我爱测

I would like to control my HAproxy remotely during deploy of applications. E.g. before stopping apps on "app-server1" I want to instruct the HA-proxy to disable the backend server "app-server1". When the application is running ag…

问题原文

原帖链接 · Leif John · CC BY-SA 3.0

I would like to control my HAproxy remotely during deploy of applications. E.g. before stopping apps on "app-server1" I want to instruct the HA-proxy to disable the backend server "app-server1". When the application is running again, I want to issue the enable command.

With "stats socket ..." I create either a UNIX socket or a TCP socket. For remote access it has to be a TCP socket. However, this obviously opens up a vulnerability that I want to mitigate.

Can I restrict the access to the admin socket, e.g. by client IP list, SSL or other?

Due to the limited amount of information I find on this topic when searching, I wonder if there is another, recommended way of remote operation for my use case?

I do use scripting for this, but allowing SSH access for the scripts to the server where HA-proxy is running, is not an option.

已采纳解答

原帖链接 · Leif John · CC BY-SA 3.0

Define a backend server pointing to the stats socket on localhost. Then set the stats socket to bind on 127.0.0.1 only. Finally, add needed ACLs to the frontend definition.

The stats socket is now restricted to accept connections only from localhost, while your frontend proxy takes care of remote clients.

global
    daemon
    stats socket 127.0.0.1:1999
    ...

frontend stats-frontend
    bind *:2000
    default_backend stats-backend
    acl ...
    acl ...

backend stats-backend
    mode tcp
    server stats-localhost localhost:1999

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-02-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。