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

How to properly proxy redis behind HAProxy?

· 52CE 我爱测

I am configuring HAproxy and would love using with Redis, my configuration is fairly simple: global maxconn 50000 defaults timeout connect 10s timeout client 30s timeout server 30s log global mode http option httplog maxconn 3000…

问题原文

原帖链接 · ciaoben · CC BY-SA 4.0

I am configuring HAproxy and would love using with Redis, my configuration is fairly simple:

global
    maxconn 50000

defaults
    timeout connect 10s
    timeout client 30s
    timeout server 30s
    log global
    mode http
    option httplog
    maxconn 3000

frontend redis
    log /dev/log local0 debug
    mode tcp

    bind *:7899
    default_backend redis_servers

backend redis_servers
    server r01 xxx:7899

but when I try to connect to the address with the CLI:

redis-cli -h loadbalancer.test.app -p 7899

I get this log:

Jul 18 15:19:24 lb01 haproxy[114128]: 217.XXX.XX.XXX:279XX [18/Jul/2022:15:19:24.426] redis redis/<NOSRV> -1/-1/0 0 PR 1/1/0/0/0 0/0

I verified and the redis server is working properly, if I execute the same command to connect to it, but with the ip of the machine directly, I can use it with success.

Anyone can help me understand what I am missing?

Thanks

已采纳解答

原帖链接 · Towfeeq Pandith · CC BY-SA 4.0

In your defaults section, the mode is http, same mode is used by your backend. You either need to change mode in your defaults section from http to tcp or explicitly add the mode as tcp under backend as the redis used tcp.

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

资料来源与适用范围

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

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

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