使 Haproxy 从前端路径转换为后端根

使 Haproxy 从前端路径转换为后端根

我想从互联网访问我的 nextcloud 实例。它在我的网络内可通过 cloud.daninet.local 访问,我想通过 mydomain.com/cloud 在外部访问它。这是我目前想到的配置:

frontend hass
    bind                    MY_EXTERNAL_IP
    mode                    http
    log                     global
    option                  httplog
    option                  http-keep-alive
    option                  forwardfor
    acl https ssl_fc
    http-request set-header         X-Forwarded-Proto http if !https
    http-request set-header         X-Forwarded-Proto https if https
    timeout client          30000
    acl                     cloud   var(txn.txnpath) -m beg -i /cloud
    acl                     hass    var(txn.txnpath) -m beg -i /cloud
    acl                     aclcrt_hass     var(txn.txnhost) -m reg -i ^MY_DOMAIN(:([0-9]){1,5})?$
    http-request set-var(txn.txnpath) path
    http-request set-var(txn.txnhost) hdr(host)
    use_backend hass_ipvANY  if  !hass aclcrt_hass
    use_backend nextcloud_ipvANY  if  cloud aclcrt_hass

backend nextcloud_ipvANY
    mode                    http
    id                      102
    log                     global
    timeout connect         30000
    timeout server          30000
    retries                 3
    acl                     all     var(txn.txnhost) -m str -i asdfaefawdfasf
    http-request set-var(txn.txnhost) hdr(host)
     reqrep ^([^\ ]*\ /)cloud[/]?(.*)     \1\2
    server                  cloud.daninet.local 192.168.1.7:443 id 101 ssl check inter 1000  ca-file /var/etc/haproxy/ca_5d29b4f7c9c1f.pem crt /var/etc/haproxy/server_clientcert_5de3a4922aebc.pem

现在,当我打开 mydomain.com/cloud 时,我会转到 mydomain.com/login,而不是 mydomain.com/cloud/login。我还尝试让 nextcloud 在 cloud.daninet.local/cloud 上运行,但显然 docker 版本中存在一些错误,因此这不是一个选项。

有人能帮我吗?

相关内容