HAProxy 背后的传输 Torrent - HTTP 响应 Header 用作 session 标识符和粘性令牌

Transmission Torrent behind HAProxy - HTTP Response Header used as session identifier and stickiness token

我一直在尝试 运行 HAProxy 背后的传输,但到目前为止都失败了。

如果我只是添加一个新的后端并按如下方式路由流量:

frontend http-in
    bind *:80
    reqadd X-Forwarded-Proto:\ http

    acl host1 hdr_end(host) -i web.host1.host
    use_backend apache_backend if host1

    acl transmission_host hdr_end(host) -i transmission.host1.host
    use_backend transmission_backend if transmission_host

然后我收到一个 409 冲突错误,指出我有一个无效的 session-id header。这很明显并且在意料之中,因为中间有一个代理。

我想过重新编译传输以摆脱检查,但最终决定面对更多学习 HAProxy 的挑战。我想到了什么?

  1. Client reaches HAProxy
  2. HAProxy connects to transmission-daemon
  3. Daemon replies with X-Transmission-Session-Id
  4. HAProxy stores the Session-Id somehow and replaces Session-Id sent by the client with the one captured by HAProxy.

经过大量谷歌搜索和调整设置后,我得到了一个几乎可以工作的配置:

frontend http-in
    bind *:80
    reqadd X-Forwarded-Proto:\ http

    capture response header X-Transmission-Session-Id len 48

    acl host1 hdr_end(host) -i web.host1.host
    use_backend apache_backend if host1

    acl transmission_host hdr_end(host) -i transmission.host1.host
    use_backend transmission_backend if transmission_host

backend transmission_backend
    mode http
    http-request set-header X-Transmission-Session-Id %hs

    server transmission-daemon transmission.intranet:9091

我的配置实例总结了。

有点用。我收到传输登录提示,但页面加载速度非常慢。我已经超过 10 分钟了,但仍然没有完全加载。

更多页面通过此代理:HTTP、HTTPS、TCP,一些负载平衡,一些设置为 fail-overs。它们都正常且快速地加载。如果我直接连接到 transmission-daemon 服务器,它加载速度也很快。

我会继续四处看看。

有什么想法吗?

提前致谢!

3年后, 根据我在 https://gist.github.com/yuezhu/93184b8d8d9f7d0ada0a186cbcda9273

中看到的内容

您应该在前端 http-in 中捕获请求和响应, 没多挖,不过后端貌似需要

stick-table type binary len 48 size 30k expire 30m
stick store-response hdr(X-Transmission-Session-Id)
stick on hdr(X-Transmission-Session-Id)

上班