Cloudflare tunnel to Nextcloud on Scale redirects to internal IP

Evaninc.

Cadet
Joined
Nov 7, 2023
Messages
1
Hi, this seems to be a similar problem to others, but I am using the official Nextcloud app and the official Cloudflared app.

I'm trying to use Cloudflare tunnels to access my Nextcloud instance running on TrueNAS scale 23.10.0.1.

I have the official Cloudflared app set up and working (I have tested it with other internal assets) and I have the official Nextcloud app up and running as well (I can access it internally).

However when I use the tunnel to access next cloud from outside of my network, it hangs for 30 seconds or so and then just redirects to the internal IP address that obviously does not work outside of the network.

I see some mentions of adding my domain as a trusted domain, and while I am not sure how to do that so I have not tried, that also does not seem like the problem.
I am not getting the "trusted domains" error, its just not pointing properly.

Again, if I point the tunnel at other services, plex for example, it works fine (http://10.10.10.82:32400/) but if I point it at Nextcloud it does not (https://10.10.10.4:9001/)

Im wondering if maybe its the "Certificate Configuration - 'truenas_default' Certificate" that i selected making it Https? And if I don't use the certificate it would just be http and work?

I think the certificate is only needed for collabora that I don't really need for this install.

Most of the other discussions and guides I have seen on this topic are for TrueCharts versions or for much older versions of various apps. It seems like the Cloudflraed app is new ish, so not much documentation yet.

I am also aware of the file size limitation on Tunnels and I will probably just end up paying for the service once I get it working.

Thanks in advance. EK
 

Kilo95

Cadet
Joined
Jun 16, 2022
Messages
2
Evaninc,
I've run into the same issue. Cloudflare works fine to access truenas from outside my network. Also can access my home assistant VM from my cloudflare tunnel. I get the same redirect to internal IP with Nextcloud. I HAVE added my cloudflare external IP and my Truenas IP to trusted domains. I'd really like to get this to work
 

LordJabu

Cadet
Joined
Jan 9, 2024
Messages
4
I had the same issue and currently seem to have fixed it. I tried a few things and I'm unsure which thing or combination of things fixed it.

The one I suspect solved it was making the "Nextcloud host" field blank in the app settings through the TrueNAS GUI.

In case it helps someone else I also set the 'overwritehost' setting to the domain I am using to access Nextcloud through tunnels.

For example: 'overwritehost' => 'nextcloud.example.com',

I also added the domain to the 'trusted_domains' array.

For example:

'trusted_domains' =>

array (

0 => 'localhost',

1 => 'nextcloud.example.com',

),

These settings are in the config.php file which can be found under the config directory wherever you set the Nextcloud Data Volume.

Lastly, I set “No TLS Verify” to be enabled on the public hostname page in Cloudflare when setting up the subdomain for Nextcloud. I have no idea if this is helping, and I take no responsibility if this is a security problem. I don’t know what I am doing *disclaimer*

I didn’t bother to change the config file back to the original since I’m just happy it works at all now and I don’t want to break it again, so I don’t know if those settings are contributing to it working. Changing the "Nextcloud host" field was what finally made it work after changing those other settings though.

Hope this helps the next lost soul :D
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
I had the same issue and currently seem to have fixed it. I tried a few things and I'm unsure which thing or combination of things fixed it.

The one I suspect solved it was making the "Nextcloud host" field blank in the app settings through the TrueNAS GUI.

In case it helps someone else I also set the 'overwritehost' setting to the domain I am using to access Nextcloud through tunnels.
This is probably what solved it. You should also set this same domain in the “Nextcloud Host” box in app settings.
For example: 'overwritehost' => 'nextcloud.example.com',
You can add this as a variable when setting up the app
OVERWRITE_HOST and the value as your domain.
I also added the domain to the 'trusted_domains' array.

For example:

'trusted_domains' =>

array (

0 => 'localhost',

1 => 'nextcloud.example.com',

),

These settings are in the config.php file which can be found under the config directory wherever you set the Nextcloud Data Volume.
This should automatically fill if you set the above variable.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
 

Krikke

Cadet
Joined
May 18, 2023
Messages
1
This is probably what solved it. You should also set this same domain in the “Nextcloud Host” box in app settings.

You can add this as a variable when setting up the app
OVERWRITE_HOST and the value as your domain.

This should automatically fill if you set the above variable.

I can confirm that removing the entry in "Nextcloud host" is what also fixed it for me. I have tried numerous other things, which did not help. This deffinitely did the trick. Thanks for sharing!
 

Attachments

  • nextcloud host.jpg
    nextcloud host.jpg
    13.4 KB · Views: 85
Top