Nextcloud Snap with nginx reverse proxy in front - infinite login loop

Hi folks,

I am already quite desperate after playing several days with the same problem.

I have set up a Ubuntu 18.04.04 LTS server with nextcloud 17.0.3snap1. This works fine, https is not enabled because this should be done by the reverse proxy.

Additonally I have set up a second Ubuntu 18.04.04 LTS server with nginx 1.14.0 as the reverse proxy. Plan is to have the nextcloud server and another web server side-by-side on one public ip, separated by the domain name.

Since days I am stuck with the problem that I can access nextcloud server via the domain (https certificat on nginx from LetsEncrypt) but I can not login to nextcloud, infinite login loop.

Local acces to the IP of the nextcloud server is ok, I can login and nextloud is working fine. Only access via nginx is creatig the infinite login loop.


Nextcloud Server:
Ubuntu 18.04.4 LTS

  • nextcloud 17.0.3snap1
  • setting for trusted domain added with command:
    nextcloud.occ config:system:set trusted_domains 1
    nextcloud.occ config:system:set trusted_domains 2 --value=192.168.x.x (IP of reverse proxy Server)

Ubuntu 18.04.4 LTS

  • nginx 1.14.0

Configuration of nginx
server {
listen 80;

    location / {
            proxy_headers_hash_max_size 512;
            proxy_headers_hash_bucket_size 64;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            add_header Front-End-Https on;
            proxy_pass; #IP des Nextcloud-Servers

	listen 443 ssl; # managed by Certbot
	ssl_certificate /etc/letsencrypt/live/xxxxxxxxxxxxxxxxxxxx/fullchain.pem$
	ssl_certificate_key /etc/letsencrypt/live/xxxxxxxxxxxxxxxx/privkey.p$
	include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
	ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


I have already done an extensive research in internet, found a lot of similar problems. Most of them were diskussion the follwoing config commands:

nextcloud.occ config:system:set overwritehost --value=“
nextcloud.occ config:system:set overwriteprotocol --value=“https”

Nextcloud documentation for reverse proxy says what to do

But I am not clear that I have understood everything correctly. And this documentatin is not for snap package.

Any ideas? What to test next? Where to look next?

1 Like

Did you solve this? I’m having sort of the same issues here…

Hi @vahirua

I don’t use NGINX or the Snap Package myself, so I haven’t tested it myself. But maybe this will help you…