Logout not working properly

Nextcloud version : 16.0.0
Operating system and version : CentOS Linux release 7.6.1810
Apache or nginx version : Nginx 1.14.1 for the proxy, not sure about apache.
PHP version : 7.3.5

I’m currently doing my first installation of nextcloud using docker-compose. I followed these instructions: https://blog.ssdnodes.com/blog/installing-nextcloud-docker/ My docker-compose.yml file is set up exactly as described:

version: '3'  

services:

  proxy:
    image: jwilder/nginx-proxy:alpine
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy=true"
    container_name: nextcloud-proxy
    networks:
      - nextcloud_network
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./proxy/conf.d:/etc/nginx/conf.d:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - ./proxy/certs:/etc/nginx/certs:ro
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    restart: unless-stopped

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: nextcloud-letsencrypt
    depends_on:
      - proxy
    networks:
      - nextcloud_network
    volumes:
      - ./proxy/certs:/etc/nginx/certs:rw
      - ./proxy/vhost.d:/etc/nginx/vhost.d:rw
      - ./proxy/html:/usr/share/nginx/html:rw
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: unless-stopped

  db:
    image: mariadb
    container_name: nextcloud-mariadb
    networks:
      - nextcloud_network
    volumes:
      - db:/var/lib/mysql
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MYSQL_ROOT_PASSWORD=supersaferootpassword
      - MYSQL_PASSWORD=supersafepassword
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
    restart: unless-stopped

  app:
    image: nextcloud:latest
    container_name: nextcloud-app
    networks:
      - nextcloud_network
    depends_on:
      - letsencrypt
      - proxy
      - db
    volumes:
      - nextcloud:/var/www/html
      - ./app/config:/var/www/html/config
      - ./app/custom_apps:/var/www/html/custom_apps
      - ./app/data:/var/www/html/data
      - ./app/themes:/var/www/html/themes
      - /etc/localtime:/etc/localtime:ro
    environment:
      - VIRTUAL_HOST=cloud.mydomain.com
      - LETSENCRYPT_HOST=cloud.mydomain.com
      - LETSENCRYPT_EMAIL=myemail@email.com
    restart: unless-stopped

volumes:
  nextcloud:
  db:

networks:
  nextcloud_network:

Logging in works fine and everything looks good as far as I can tell, but when I try to log out I get a spinning circle next to the log out button, and the status bar in the bottom left corner says “Processing request…”. It will stay this way for hours with nothing else happening. If I refresh the page it completes the logout and brings me to the login screen, where I can log in normally again, but this isn’t acceptable long-term.

The error log at nextcloud -> admin -> logging comes up completely blank.

Here’s the original, default configuration of the config.php which didn’t work:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'instanceid' => 'oczxktutryhm',
  'passwordsalt' => 'VlonbHXJGQsvf83ICU34aykBmZnlIm',
  'secret' => 'g0Siht01VmZF/iGnagtpFrX7ezzi9epYa5QCVKFYvQvmFuPx',
  'trusted_domains' =>
  array (
    0 => 'cloud.mydomain.com',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '16.0.0.9',
  'overwrite.cli.url' => 'http://cloud.mydomain.com',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud',
  'dbpassword' => 'mypassword',
  'installed' => true,
  'overwrite.cli.url' => 'https://cloud.mydomain.com',
);

I then tried changing my trusted domains and overwritehost as recommended in similar cases (rest remained the same):

...
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'cloud.editcontent.online',
    2 => '78.47.80.70',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '16.0.0.9',
  'overwritehost' => 'cloud.mydomain.com',
  'overwriteprotocol' => 'https',
...

This seemed to make no difference whatsoever.

This is the output of the apache log when I hit the logout button:

172.19.0.2 - - [15/May/2019:23:59:23 +0200] "GET /logout?requesttoken=SjfvLUbepfLlZAK3W%2FYSB%2B90NBf%2FiYuS%2BqXQ0fnOk48%3D%3AEGS4RiOu7cCkEkbma89%2Fb8ANQy%2Bovt37v%2FS2iZ2b8dk%3D HTTP/1.1" 303 1737 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36"

I’ve spent several hours scouring the web without finding a solution, so any input will be greatly appreciated.

It looks like my error was a version of this: https://github.com/nextcloud/server/issues/9179

After spending a solid 5 hours trying to figure it out, it turns out the fix was as simple as clearing my browser’s cache… Works beautifully now.