微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Haproxy 似乎在“Accept-Encoding”标头中用 gzip 替换了 brotli

如何解决Haproxy 似乎在“Accept-Encoding”标头中用 gzip 替换了 brotli

我正在努力弄清楚为什么 haproxy 在请求通过 haproxy 时似乎在“Accept-Encoding”标头中用 gzip 替换了 br

我的应用程序目前的结构如下:

HAPROXY(tls termination) -> varnish -> apache 

所以我是这样测试的:

curl -I --http2 -H 'Accept-Encoding: br' -I https://mysite.dev:31753?tru

因此 - 向 haproxy 发送单个 GET 请求,该请求仅严格要求(使用 curl)...
所以这就是我希望看到的清漆,但实际上进入清漆的是这两个请求:

  • 带有 br
  • 的 HEAD 请求
  • 使用 gzip 值代替 GET 请求...

我很困惑 - 为什么现在有 2 个请求?我没有在 haproxy 中配置压缩如何将 br 重写为 gzip

进入清漆的请求(我使用 tcpflow 程序得到这个):

172.030.000.035.41382-172.030.000.034.00080: HEAD /?tru HTTP/1.1
user-agent: curl/7.68.0
accept: */*
accept-encoding: br
host: mysite.dev:31753
x-client-ip: 192.168.10.103
x-forwarded-port: 31753
x-forwarded-proto: https
x-forwarded-for: 192.168.10.103
connection: close


172.030.000.034.41882-172.030.000.033.00080: GET /?tru HTTP/1.1
user-agent: curl/7.68.0
accept: */*
x-client-ip: 192.168.10.103
x-forwarded-port: 31753
x-forwarded-proto: https
X-Forwarded-For: 192.168.10.103,172.30.0.35
host: mysite:31753
Accept-Encoding: gzip
X-Varnish: 328479

我的 haproxy 配置如下:

Haproxy

global
    maxconn 1024
    log stdout format raw local0
    ssl-default-bind-options ssl-min-ver TLSv1.2

defaults
    log global
    option  httplog
    option  http-server-close
    mode    http
    option  dontlognull
    timeout connect 5s
    timeout client 20s
    timeout server 45s

frontend fe-wp-combined
    mode tcp
    bind *:31753
    tcp-request inspect-delay 2s
    tcp-request content accept if HTTP
    tcp-request content accept if { req.ssl_hello_type 1 }
    use_backend be-wp-recirc-http if HTTP
    default_backend be-wp-recirc-https

backend be-wp-recirc-http
    mode tcp
    server loopback-for-http abns@wp-haproxy-http send-proxy-v2

backend be-wp-recirc-https
    mode tcp
    server loopback-for-https abns@wp-haproxy-https send-proxy-v2

frontend fe-wp-https
    mode http
    bind abns@wp-haproxy-https accept-proxy ssl crt /certs/fullkeychain.pem alpn h2,http/1.1
    # whatever you need todo for HTTPS traffic
    default_backend be-wp-real

frontend fe-wp-http
    mode http
    bind abns@wp-haproxy-http accept-proxy
    # whatever you need todo for HTTP traffic
    redirect scheme https code 301 if !{ ssl_fc }

backend be-wp-real
    mode http
    balance roundrobin
    option forwardfor

    # Send these request to check health
    option httpchk
    http-check send meth HEAD uri / ver HTTP/1.1 hdr Host haproxy.local

    http-response del-header Server
    http-response del-header via

    server wp-backend1 proxy-varnish:80 check
    http-request set-header x-client-ip %[src]
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }

如果有人知道这里发生了什么,请帮忙 - 非常难倒。

解决方法

nvm.在进一步调查后发现我混淆了 tcpflow 结果。

显然它一直是自动编码 gzip 的清漆,在我禁用它之后 - 我按预期恢复了。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。