Mobile App can't login with reverse proxy

Hi,
I am following the template in docker/Dockerfile at master · nextcloud/docker · GitHub to create my own nextcloud image with a couple of modifications like changing imagemagick policies and installing ghostscript.
I currently have haproxy which offloads https for a few other servers I have so I added this container to the list. however when I try login in via the android app it stays loading but it never logins. If I try the container directly I can login via the android app immediately. note that the website works without problems with the reverse proxy.
I have set the overrides in the nextcloud config file i.e overwrite.cli.url, overwritehost, overwriteprotocol, also trusted_proxies. but I can’t make it work.
I have tried using nginx as proxy, and also the jwilder/nginx-proxy:alpine image and still no luck. I am really keen to be using nextcloud as container but I can’t get it to work

here is my Dockerfile

    FROM nextcloud:apache

RUN set -ex; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
    ffmpeg \
    libmagickcore-6.q16-6-extra \
    procps \
    ghostscript \
    smbclient \
    supervisor \
#       libreoffice \
    ; \
    rm -rf /var/lib/apt/lists/*

RUN set -ex; \
    \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        ghostscript \
    ; \
    rm -rf /var/lib/apt/lists/*

RUN set -ex; \
    \
    savedAptMark="$(apt-mark showmanual)"; \
    \
    apt-get update; \
    apt-get install -y --no-install-recommends \
        libbz2-dev \
        libc-client-dev \
        libkrb5-dev \
        libsmbclient-dev \
    ; \
    \
    docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \
    docker-php-ext-install \
        bz2 \
        imap \
    ; \
    pecl install smbclient; \
    docker-php-ext-enable smbclient; \
    \
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
    apt-mark auto '.*' > /dev/null; \
    apt-mark manual $savedAptMark; \
    ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
        | awk '/=>/ { print $3 }' \
        | sort -u \
        | xargs -r dpkg-query -S \
        | cut -d: -f1 \
        | sort -u \
        | xargs -rt apt-mark manual; \
    \
    apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
    rm -rf /var/lib/apt/lists/*

 COPY policy.xml /etc/ImageMagick-6/

RUN mkdir -p \
    /var/log/supervisord \
    /var/run/supervisord \
;

#JN add to remove default files per new user
RUN rm -rf /var/www/html/core/skeleton/*

COPY supervisord.conf /

ENV NEXTCLOUD_UPDATE=1

CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

also my docker-compose
version: ‘2’

services:

  nginx-proxy:
    image: jwilder/nginx-proxy
    ports:
      - "443:443"
      - "80:80"
    volumes:
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - /containers/httpd/conf/certs:/etc/nginx/certs
  db:
    image: postgres
    restart: always
    volumes:
      - /containers/nextcloud/postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nc
      - POSTGRES_PASSWORD=somepassword
  redis:
    image: redis:alpine
    restart: always
  collabora:
    image: collabora/code
    restart: always
    ports:
      - 9980:9980
    volumes:
      - /containers/nextcloud/data:/var/www/html/data
  app:
    image: nextcloud_jn
    ports:
      - 80:80
    links:
      - db
    volumes:
      - /containers/nextcloud/html:/var/www/html
      - /containers/nextcloud/apps:/var/www/html/custom_apps
      - /containers/nextcloud/config:/var/www/html/config
      - /containers/nextcloud/data:/var/www/html/data
    environment:
      - POSTGRES_HOST=db
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=nc
      - POSTGRES_PASSWORD=somepassword
      - REDIS_HOST=redis
      - OVERWRITEPROTOCOL=http
      - SMTP_HOST=smtp.gmail.com
      - SMTP_SECURE=tls
      - SMTP_PORT=587
      - SMTP_AUTHTYPE=LOGIN
      - SMTP_NAME=myemail
      - SMTP_PASSWORD=emailpassword
      - MAIL_FROM_ADDRESS=fromemail
      - MAIL_DOMAIN=domain
      - VIRTUAL_HOST=domain.end
    depends_on:
      - db
      - redis
    restart: always

config.php

<?php
$CONFIG = array (
  'overwriteprotocol' => 'https',
  '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,
    ),
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'redis',
    'password' => '',
    'port' => 6379,
  ),
  'mail_smtpmode' => 'smtp',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_smtpport' => '587',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauth' => true,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => 'email',
  'mail_smtppassword' => 'password',
  'mail_from_address' => 'nc',
  'mail_domain' => 'somedomain.end',
  'instanceid' => 'someid',
  'passwordsalt' => 'salt',
  'secret' => 'secret',
  'trusted_domains' => 
  array (
    0 => '192.168.13.111:8081',
    1 => 'domain.end',
    2 => 'otherdomain.end',
    3 => 'app',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '20.0.6.1',
  'overwrite.cli.url' => 'https://domain.end',
  'overwritehost' => 'domain.end',
  'dbname' => 'nextcloud',
  'dbhost' => 'db',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => 'password',
  'installed' => true,
  'default_locale' => 'en_AU',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',
  'enabledPreviewProviders' =>
  array (
    1 => 'OC\\Preview\\BMP',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\HEIC',
    4 => 'OC\\Preview\\JPEG',
    5 => 'OC\\Preview\\MarkDown',
    6 => 'OC\\Preview\\MP3',
    7 => 'OC\\Preview\\PNG',
    8 => 'OC\\Preview\\TXT',
    9 => 'OC\\Preview\\XBitmap',
    10 => 'OC\\Preview\\Movie',
    11 => 'OC\\Preview\\PDF',
    12 => 'OC\\Preview\\MP4',
    13 => 'OC\\Preview\\AVI',
    14 => 'OC\\Preview\\MKV',
  ),
  'logfile' => 'nextcloud.log',
  'loglevel' => 0,
  'maintenance' => false,
  'trusted_proxies' =>
  array (

0 => '172.17.42.1',
1 => '192.168.11.254',
2 => '172.29.0.1',
3 => '172.26.0.0/24',
  ),
);

please help
thanks

it is all fixed by the OVERWRITEPROTOCOL option. my config had a conflict of values. docker compose was setting OVERWRITEPROTOCOL to http while the nextcloud config had OVERWRITEPROTOCOL to https.
setting both to https fixes the issue

1 Like