请求在HAproxy上没有命中端口80

我正在configurationHAProxy将httpredirect到https,但似乎不起作用。 我使用的configuration是:

/etc/hosts内容

 127.0.0.1 example.com 

Haproxyconfiguration

 frontend http mode http bind :80 bind :443 ssl crt /etc/ssl/ redirect scheme https if !{ ssl_fc } default_backend my_backend 

用curltesting给出这个错误

 $ curl https://example.com < this works $ curl http://example.com > curl: (7) Failed to connect to 2400:cb00:2048:1::681c:a20: No route to host 

但是,命令lsof已经输出

 $ sudo lsof -i :80 | grep LISTEN haproxy 7290 root 4u IPv4 0x9485b36892b5495d 0t0 TCP *:http (LISTEN) 

我不知道在这种情况下有什么问题。 这是我第一次在Haproxy上configurationSSL。

我在HAProxy中有一个非常类似的设置。 我只能find你的configuration和我的两个区别。

  1. /etc/hosts我将example.com绑定到了0.0.0.0而不是127.0.0.1
  2. 在我的前端,两个bind条目都在冒号前包含一个通配符( * )。 例:

     bind *:80 bind *:443 ssl crt /etc/ssl/ssl.pem 

    2A。 我实际上在我的configuration中使用了一个pem文件(如上所述),但是看起来像curl https://example.com工作,这不太可能是这个问题。

我也build议看一下netstat -tulpn | grep haproxy的输出 netstat -tulpn | grep haproxy了解HAProxy绑定的更多细节。

希望有所帮助。