Tom Wojcik personal blog

Fix NextCloud login on Android app

☕️ 1 min read

In my homelab I use NextCloud as a drop-in replacement for Google Drive / Dropbox. Even though I was able to login via the browser to my nextcloud.example.com instance (from both mobile and PC), I wasn’t able to login using the official app on Android.

I was getting error “Strict mode: No HTTP connection allowed”.

In my setup, Traefik is sitting in front of NextCloud and is responsible for SSL and proxying the traffic to my homelab.

I run into “Using the apache image behind a reverse proxy and auto configure server host and protocol” docs section. It provides a set of environment variables that overwrite the main config file.

If we jump to the definition of overwriteprotocol in the config file, it says

/**
 * When generating URLs, Nextcloud attempts to detect whether the server is
 * accessed via ``https`` or ``http``. However, if Nextcloud is behind a proxy
 * and the proxy handles the ``https`` calls, Nextcloud would not know that
 * ``ssl`` is in use, which would result in incorrect URLs being generated.
 * Valid values are ``http`` and ``https``.
 */

which is exactly what we want! NextCloud, when not aware of the reverse proxy, uses http by default.

After adding this environment variable to my nextcloud service, I was able to log in via the mobile app.

environment:
 - OVERWRITEPROTOCOL=https

You can see my final compose file for NextCloud in my public homeserver repository.