[Solved] Nextcloud behind 2 Nginx resolves wrong IP when using desktop app


I have the following setup (all with DietPi installed)

Raspberry A // has NGINX as web server // has 2 VPNs set up
Raspberry B // has Nextcloud // has NGINX as web server // has VPN connection to RPiA and viceversa

B has all default settings/default installation of nextcloud and nginx using dietpi-software

A has 2 VPNs, one is for admin/internal wiring between raspberries. Other is for external use by actual users. This is done this way because raspberries are in different physical places and users don’t have to have direct access to B.

The NGINX on this raspberry is configured in such a way that if somebody calls http://raspberryA/nextcloud it gets redirected to raspberry b /nextcloud (but users of that vpn do not see that there are 2 raspberries)

Web interface works like a charm

Problem comes when using the desktop app. For some reason, when desktop app asks for url, and user inputs http://raspberryA/nextcloud a browser window gets opened and the URL that appears on it has the form where is the IP address of the internal VPN of the raspberry B. This IP is not accessible for end users (they are on the non-internal VPN) so they get an error.

I’m posting this here because I assume that this is something related to nextcloud’s config with DietPi that for some reason when resolving the URL for token auth/login it provides the first IP the actual machine has, instead of using the URL inputted by the user, but I can’t see any place where this is configurable.

Is there any way to configure this? I can provide config files if required but I don’t know what will be required…

Sorry I thought this was DietPi issue, but it was not. It’s NextCloud that has problems running behind certain reverse proxy situations and can’t detect the host correctly

I fixed this by manually adding a config in config/config.php which is overwritehost with value raspberryA.local (the domain of my raspberry pi A)

The following link has detailed explanation

thx for sharing this interesting setup and solution. Much appreciated.

1 Like