NextCloud on Caddy


(Jack Elbar) #1

Trying to set up Nextcloud to run on Caddy reverse proxy. I’ve spent hours trying to get it to work, to no avail.

Here is my caddy file:

cloud.mysite.com {
    gzip
    proxy / https://192.168.2.3:500 {
      transparent
      websocket
      insecure_skip_verify
      }
}

I’ve tried a lot of versions of this, but nothing works.

Here is my config file for Nextcloud:

      'trusted_domains' => 
      array (
        0 => '192.168.2.3:500',
        1 => '192.168.2.15:2015',
        2 => '192.168.2.15:443',
        3 => '192.168.2.15:80',
        4 => 'cloud.mysite.com',
        5 => 'https://cloud.mysite.com',
      ),

192.168.2.15 is Caddy. I’ve tried different trusted domains, but again, nothing works.

Whatever I do, I get 502 bad gateway.

Would really appreciate any insight!t!


(Matthew Fay) #2

Something that might tell us what’s going on is to try and pretend to be Caddy, requesting a page from Nextcloud, and see what we get.

Run the command curl -kIL https://192.168.2.3:500/ -H "Host: cloud.mysite.com" (changing cloud.mysite.com as appropriate) from the host Caddy is running on and let us know what comes back.


(Austin Lakeman) #3

Not sure how much help i could be but i run Nextcloud in a docker container on a separate VM. and here is my caddyfile (with 100% non-relevant info excluded):

####################################################################################
# Snippets
####################################################################################

(mycommon_tls) {
  ext .html .htm .php
  root /var/www          # Change path & syntax for your OS or your preferred location!
  gzip
  tls admin@domain.com {
  }
  header / {
    X-Content-Type-Options nosniff
    X-XSS-Protection "1; mode=block"
    Strict-Transport-Security "max-age=31536000;"
  }
}

####################################################################################
# web domain server block
####################################################################################
 
domain.com {
 
  # New log directive syntax for v0.10.x
  log /var/log/caddy/logs/access.log {                          # Change path syntax for your OS or your preferred location!
    rotate_size 1          # Rotate after 1 MB
    rotate_age  7          # Keep log files for 7 days
    rotate_keep 2          # Keep at most 2 log files
  }
 
  errors /var/log/caddy/logs/error.log {                        # Change path syntax for your OS or your preferred location!
    rotate_size 1          # Set max size 1 MB
    rotate_age  7          # Keep log files for 7 days
    rotate_keep 2          # Keep at most 2 log files
  }
 
  import mycommon_tls        # Import code snippet 1 defined above
  #import mylocations        # Import code snippet 2 defined above
 
}

####################################################################################
# NextCloud Subdomain
####################################################################################
cloud.domain.com {
  import mycommon_tls
  proxy / https://cloud.lan.domain.com {
        transparent
        insecure_skip_verify
    }
    log /var/log/caddy/access.cloud.log
    errors /var/log/caddy/errors.cloud.log
}