Help - NextCloud Domain Redirects to Apache2 Debian Default Page

Hi,

I’m trying to use Caddy to reverse proxy to my NextCloud server. However when I use Caddy I get the Apache2 Debian Default Page. I can get to nextcloud just fine when I type 192.168.1.21 and it takes me to 192.168.1.21/index.php/login.

Here is my CaddyFile entry for NextCloud

ncloud.skywave.com {
gzip
proxy / 192.168.1.21 {
transparent
}
tls example@domain.com
}

I’m not sure if more information is needed for the CaddyFile.

Does typing ncloud.skywave.com/index.php/login have a different result?

What happens when you curl -H "Host:ncloud.skywave.com" 192.168.1.21 from your Caddy host?

Thanks for the reply!

I tried typing ncloud.skywave.com/index.php/login and I get:

Not Found

The requested URL /index.php/login was not found on this server.

Apache/2.4.25 (Debian) Server at ncloud.skywave.com Port 80

and when I do curl -H “Host:ncloud.skywave.com” 192.168.1.21, I get the Apache2 Debian Default Page

This part effectively means that Caddy isn’t listening on port 80 on host 192.168.1.21, so you will need to log on to that host, stop Apache, and start Caddy.

Edit: Not relevant, shouldn’t comment while tired :frowning_face:

Ok I stopped Apache on 192.168.1.21 and restarted Caddy. Now I get a 502 Bad Gateway

Oh, man, I shouldn’t be commenting when I’m tired… Please disregard the majority of the last comment, sorry.

So, 192.168.1.21 should be the host your Nextcloud is running on… How have you configured your Nextcloud server, exactly?

I followed this guide How to Install NextCloud on Debian 9 Stretch with LAMP - LinuxBabe

and in the Apache Virtual Host file next to ServerName I put the ip address of the server.

EDIT: Here is my virtual Host File

    <VirtualHost *:80>
 DocumentRoot "/var/www/nextcloud"
 ServerName 192.168.1.21
 
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 
<Directory /var/www/nextcloud/>
 Options +FollowSymlinks
 AllowOverride All
 
 <IfModule mod_dav.c>
 Dav off
 </IfModule>
 
 SetEnv HOME /var/www/nextcloud
 SetEnv HTTP_HOME /var/www/nextcloud
 Satisfy Any
 
</Directory>
 
</VirtualHost>

Alright, go back to 192.168.1.21 and start up Apache again.

In short, your problem is that Apache configured to only serve Nextcloud to people requesting 192.168.1.21:

When Caddy is proxying from ncloud.skywave.com with the transparent preset enabled, though, it’s requesting ncloud.skywave.com from Apache, not 192.168.1.21.

You can either:

1. Tell Apache to listen for ncloud.skywave.com

Edit /etc/apache2/sites-available/nextcloud.conf, add a ServerAlias:

ServerName 192.168.1.21
ServerAlias ncloud.skywave.com

2. Tell Caddy to request 192.168.1.21

Either add header_upstream Host 192.168.1.21 to your Proxy directive, OR remove transparent. This is a bit of a hack and comes with some downsides.

Sorry, had to go to sleep.

So adding the ServerAlias did the trick! but when I add the header_upstream Host 192.168.1.21 or remove transparent Caddy stops working

ncloud.skysegue.com {
gzip
proxy / 192.168.1.21 {
header_upstream Host 192.168.1.21
}
tls flee97@live.com
}

Can’t seem to get it working without the Transparent directive

How does Caddy stop working, exactly?

You didn’t need to do both; only one of those options are needed.

Oh…ok.

So i’ve tested both options. Head_upstream Host 192.168.1.21 option causes Caddy not to issue a cert and causes a redirect to 192.168.1.21 (which leads to nothing) when typing the domain. Transparent has no such issues and a cert gets issued no problem and Nextcloud is accessible.

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