Assistance with nextcloud

Hello, I’ve recently discovered caddy and am using it to setup a reverse proxy in a VM on my home server.

I’d like to have traffic for nextcloud run through it. My nextcloud server is running on a different server than the caddy server.

I’ve found many example configurations but they all seem to based off of this: examples/nextcloud/Caddyfile at master · caddyserver/examples · GitHub

What I do not understand about this example, is how does this redirect traffic to the nextcloud server? Where do I give it the IP address of the nextcloud server? Do I simply make a line like

proxy / 192.168.0.50 { }

If so, do I need any presets? It can’t be that easy, right?

Thanks for your help with a noob.

Hi @avalanche, welcome to the Caddy community.

The example Caddyfile you linked is for Caddy to serve Nextcloud directly as a local site from PHP files on disk.

If you’ve already got Nextcloud running and available on another machine, then… Yes! It’s that easy. I think Nextcloud uses websockets for some features, so I’d use that preset. Transparency is also useful.

So here you go:

proxy / 192.168.0.50 {
  transparent
  websocket
}

https://caddyserver.com/docs/proxy

Well, I gave it a shot but got

ERR_TOO_MANY_REDIRECTS

Chrome suggested clearing cookies but that was no help.

Any suggestions as to what to look at next?

Do you have anything else in your Caddyfile?

With that proxy, Caddy will faithfully forward responses from Nextcloud to the connecting client. Unless you have misconfigured redir directives in your Caddyfile, there might be a problem with Nextcloud (perhaps it’s trying to canonically redirect, or go from HTTP->S?).

well, I tried it both as a directory and as a subdomain. Subdomain works

going to mydomain.com/nextcloud is giving me the too many redirects error

going to nextcloud.mydomain.com/nextcloud gives me the login page

I tried adding the without /nextcloud directive but that didn’t help me at all. I guess I can live with the extra nextcloud at the end because at least it’s working.

As for your questions: under mydomain.com I have several other proxies configured for other services I use. under nextcloud.mydomain.com I have just the nextcloud configuration.

regarding nextcloud configuration, I do have a cert installed on it from let’s encrypt, although HTTP is still open. I could research how to uninstall the cert and tell apache just to accept HTTP traffic. That should likely test the waters there, yes?

I don’t really have enough information to say either way.

Is Caddy even proxying to a HTTP endpoint, or to HTTPS? What’s the difference between nextcloud.mydomain.com and mydomain.com, exactly?

If you can post your entire Caddyfile, that’ll shed a lot of light on the situation.

Here is the full caddy file:

my.domain.com
{
  ext .html .htm
  root /caddy/www
  gzip
  tls myemail

  log /caddy/log/access.log {
    rotate_size 3
    rotate_age 90
    rotate_keep 25
  }

  header / {

    X-Content-Type-Options nosniff
    X-XSS-Protection "1; mode=block"
    Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
  }

 
  proxy /headphones 192.168.0.55:8181 {
	transparent
  }

  proxy /sonarr 192.168.0.55:8989 {
	transparent
  }

  proxy /couch 192.168.0.55:5050 {
	transparent
  }

  proxy /deluge 192.168.0.55:8112 {
    without /deluge
    transparent
    header_upstream X-Deluge-Base "/deluge"
  }

  proxy /web 192.168.0.176:32400 {
    transparent
  }
  
  proxy /pihole 192.168.0.182/admin {
    transparent
  }  

}


nextcloud.my.domain.com {



  log /caddy/log/nextcloud.log {
    rotate_size 3
    rotate_age 90
    rotate_keep 25
  }

  gzip
  tls my email
    proxy / 192.168.0.50/ {
	websocket
	transparent
    }
}

Looks like there’s no /nextcloud proxy under my.domain.com. Seems like your other proxy is aimed at a HTTP endpoint, though, so it can’t be a redirect loop for a HTTPS upgrade. Not sure, but there’s definitely no other redirects, so it’s strange for Nextcloud to be acting up.

As for the /nextcloud basepath on the nextcloud.mydomain.com site, there will possibly be a setting somewhere in Nextcloud itself. Or, it may simply be designed to use a subfolder that way.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.