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

How to check haproxy sni-based rule with curl?

· 52CE 我爱测

I made simple HaProxy configuration to pass thorough traffic based on SNI field. Here is my haproxy.cfg defaults log global timeout client 50s timeout client-fin 50s timeout connect 5s timeout server 10s timeout tunnel 50s fronte…

问题原文

原帖链接 · Kirill · CC BY-SA 3.0

I made simple HaProxy configuration to pass thorough traffic based on SNI field. Here is my haproxy.cfg

defaults
    log global
    timeout client 50s
    timeout client-fin 50s
    timeout connect 5s
    timeout server 10s
    timeout tunnel 50s
frontend tcp-0_0_0_0-443
    bind *:443
    mode tcp

    acl sni_acl_example_com req.ssl_sni -m sub example.com
    use_backend example_com_be if sni_acl_example_com

backend example_com_be
    mode tcp
    server name1 93.184.216.34

I run HaProxy using the following Dockerfile:

FROM haproxy:1.7.9-alpine
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
EXPOSE 443

and the following command: docker build -t my-haproxy . && docker run -p 443:443 --rm -d --name my-running-haproxy my-haproxy

Now I would like to check if the rule called sni_acl_example_com will work as expected using cURL.

curl -k -X 'GET' -H 'Host: example.com' --resolve example.com:443:127.0.0.1 https://example.com

The result is:

curl: (35) LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to example.com:443

Obviously the rules does not work and there is no suitable backend (that's why I get SSL_ERROR_SYSCALL). If I add some default_backend, it will be used instead to perform my request.

Why my cURL request does not open http://example.com using HaProxy?

I use curl 7.54.0 with latest OSX High Sierra.

已采纳解答

原帖链接 · Kirill · CC BY-SA 3.0

Figured it out. cURL request is absolutely correct.

There were 2 configuration statements missing in haproxy.cfg. In order to make sni-rules work you also need:

tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 }

under frontend section.

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

资料来源与适用范围

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

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

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