【问题标题】:nginx configs to haproxynginx 配置为 haproxy
【发布时间】:2020-09-20 05:15:03
【问题描述】:

我想要 haproxy 中的 nginx 配置。浏览了很多链接,但没有一个提到与以下配置相关的任何内容。

proxy_http_version 1.1;
proxy_set_header Connection "";

【问题讨论】:

  • 您的实际问题是什么?
  • Haproxy 将请求转发到 http1.0 中的后端服务器,但我的后端服务器支持 http1.1 及更高版本。之前我能够使用带有 abv 配置的 nginx 来实现这一点,但不能使用 hap。我有简单的 hap 后端配置 backend tune server tune <ip>:443 check ssl verify none \n \n * HTTP 1.0, assume close after body < HTTP/1.0 503 Service Unavailable < Cache-Control: no-cache < Connection: close < Content-Type: text/html < <html><body><h1>503 Service Unavailable</h1> No server is available to handle this request. </body></html> * Closing connection 0

标签: nginx reverse-proxy haproxy http-1.1


【解决方案1】:

您可以在服务器行上设置首选的alpn 协议,并在标头上设置http-request set-header

# I would prefer to set this option instead of the header
option http-server-close

http-request set-header Connection "''"
server 127.0.0.1:443 ssl crt pub.pem alpn http/1.1

你也可以使用option http-server-close

【讨论】:

  • 我尝试了您对

    http-request set-header Connection "" server 127.0.0.1:443 ssl crt pub.pem alpn http/1.1 的建议,在这两种情况下它都会抛出“hap configuration file invalid”

    [ALERT] 153/143734 (27873) : parsing [/etc/haproxy/haproxy.cfg:86]: 'http-request set- header' expects exactly 2 arguments. <br/><br/> [ALERT] 153/144145 (28175) : parsing [/etc/haproxy/haproxy.cfg:84] : 'server tune' unknown keyword 'alpn'. Registered keywords :
  • 你使用哪个版本的 haproxy?
  • HA-Proxy 版本 1.8.15 2018/12/13 http-request set-header Connection " ' ' " \n\n 这有效。 http1.1 还是不行
  • 您需要将 haproxy 更新到 2.1 才能设置 alpn。客户端是否发送 HTTP/1.0 请求?也许你需要设置主机头http-request set-header Host <HOST_OF_BACKEND>
猜你喜欢
  • 1970-01-01
  • 2020-01-03
  • 1970-01-01
  • 2012-05-19
  • 2012-08-16
  • 2014-02-06
  • 2017-07-29
  • 1970-01-01
  • 2019-08-23
相关资源
最近更新 更多