Can not proxy nextcloud correctly

Nextcloud version---------------------Docker pull nextcloud
Operating system and version-----Debian GNU/Linux 9 (stretch)
Web server------------------------------Caddy in docker
Docker version-------------------------18.06.0-ce

The Caddyfile is:

[domain.url.me]
{
gzip
proxy / 172.17.0.4:80 {
websocket
}
}

It works well at the nextcloud config web page.I visit domain.url.me to login nextcloud,and it show the config web page.

But after I press the next button and hoping everything works perfectly,the browser jump to 172.17.0.4/apps/files/.

What happened? Does the apache2 built in nextcloud docker send “172.17.0.4/apps/files/” to Caddy?And Caddy just send this to me so everything go to the wrong direction?

How I can fix this?Do I have to config apache2 in the nextcloud docker?

I think you need to use the transparent (see https://caddyserver.com/docs/proxy) directive on your proxy definition:

proxy / 172.17.0.4:80 {
    websocket
    transparent
}

This will pass through the required headers to nextcloud, allowing it to respond with the hostname you would expect.

1 Like

Yep! Nextcloud expects to see the Host header. Without transparent, Caddy would ask for 172.17.0.4 as the host, which Nextcloud uses to formulate its redirects.

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