1

I would like to access my nextcloud instance from the internet. It is reachable within my network via cloud.daninet.local, and i want to access it externally via mydomain.com/cloud. This is the config i have come up with so far:

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

Now when i open mydomain.com/cloud i get to mydomain.com/login instead of mydomain.com/cloud/login. I also tried to make nextcloud run on cloud.daninet.local/cloud, but apparently there is some bug in the docker version, so that is not an option..

Could anyone help me out here?

Daniel
  • 11
  • 1
  • Use a subdomain and save yourself all the hassle. – Michael Hampton Jun 28 '20 at 12:16
  • Sadly a subdomain won't work with restrictions in my setup regarding letsencrypt certificates. – Daniel Jun 28 '20 at 12:59
  • I see you are using `var(txn.txnpath)` but can't see where you set `txn.txnpath` or why you are using txn at all for that matter. I am guessing your acl rules do not work so header does not get rewrited at all. I would rather use something like this in backend without anything else `http-request set-path %[path,regsub(^/cloud/,/)]”` to remove the /cloud from url and then pass it to backend. I am unaware of how nextcloud handles urls thou. – seven Nov 26 '21 at 21:06

0 Answers0