Nextcloud and Swag on non-standard port

Hello,

I have been trying to set up Nextcloud and SWAG on a non-standard port, say 1234 rather than 443. I’m using Duckdns.

I have followed the SWAG and Nextcloud guide on Linuxserver. I have tried several things, but clearly there’s something in the setup that I don’t understand because I can’t get it to work.

If I go to https://nextcloud.mydomain.duckdns.org:1234, I get redirected to my router login page, instead of the Nextcloud page.

Nextcloud works if I use port 443.
And I did get to work some of the other Linuxserver containers, which are all awesome by the way, (Jellyfin, Lychee) on port ‘1234’. I didn’t have to do anything special there, when I opened port 1234 on the router I just mapped it to 443 and it worked.
I feel so close to this and yet just out of reach…

My config files

docker-compose.yaml

---
version: "2.1"
services:
  swag:
    image: lscr.io/linuxserver/swag
    container_name: swag
    cap_add:
      - NET_ADMIN
    dns: 8.8.8.8
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Athens
      - URL=mydomain.duckdns.org
      - VALIDATION=duckdns
      - SUBDOMAINS=wildcard
      - DUCKDNSTOKEN=token
    volumes:
      - /home/pi/configs/swag:/config
    ports:
      - 443:443
#      - 80:80
    restart: unless-stopped

  nextcloud:
    image: ghcr.io/linuxserver/nextcloud
    container_name: nextcloud
    dns: 8.8.8.8
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Athens
    volumes:
      - /home/pi/configs/nextcloud/config:/config
      - /home/pi/configs/nextcloud/data:/data
    depends_on:
      - mariadbnc
      - swag
    restart: unless-stopped

  mariadbnc:
    image: ghcr.io/linuxserver/mariadb
    container_name: mariadbnc
    environment:
      - PUID=1000
      - PGID=1000
      - MYSQL_ROOT_PASSWORD=password
      - TZ=Europe/Athens
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=ncuser
      - MYSQL_PASSWORD=password
    volumes:
      - /home/pi/configs/mariadbnc:/config
    restart: unless-stopped

  duckdns:
    image: lscr.io/linuxserver/duckdns
    container_name: duckdns
    dns: 8.8.8.8
    environment:
      - PUID=1000 #optional
      - PGID=1000 #optional
      - TZ=Europe/Athens
      - SUBDOMAINS=mydomain
      - TOKEN=token
      - LOG_FILE=false #optional
    volumes:
      - /home/pi/configs/duckdns:/config #optional
    restart: unless-stopped

Nextcloud config.php:

<?php
$CONFIG = array (
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'datadirectory' => '/data',
  'instanceid' => 'theid',
  'passwordsalt' => 'salt',
  'secret' => 'secret',
  'trusted_domains' => 
  array (
    0 => 'nextcloud.mydomain.duckdns.org',
    1 => 'nextcloud.mydomain.duckdns.org:1234',
  ),
  'dbtype' => 'mysql',
  'version' => '22.2.3.0',
  'overwrite.cli.url' => 'https://nextcloud.mydomain.duckdns.org',
  'dbname' => 'nextcloud',
  'dbhost' => 'mariadbnc',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncuser',
  'dbpassword' => 'password',
  'installed' => true,
  'trusted_proxies' => ['swag'],
  'overwritehost' => 'nextcloud.mydomain.duckdns.org',
  'overwriteprotocol' => 'https',
);

nextcloud.subdomain.conf:

## Version 2021/05/18
# make sure that your dns has a cname set for nextcloud
# assuming this container is called "swag", edit your nextcloud container's config
# located at /config/www/nextcloud/config/config.php and add the following lines before the ");":
#  'trusted_proxies' => ['swag'],
#  'overwrite.cli.url' => 'https://nextcloud.your-domain.com/',
#  'overwritehost' => 'nextcloud.your-domain.com',
#  'overwriteprotocol' => 'https',
#
# Also don't forget to add your domain name to the trusted domains array. It should look somewhat like this:
#  array (
#    0 => '192.168.0.1:444', # This line may look different on your setup, don't modify it.
#    1 => 'nextcloud.your-domain.com',
#  ),

server {
    listen 443 ssl;
    listen [::]:443 ssl;

    server_name nextcloud.*;

    include /config/nginx/ssl.conf;

    client_max_body_size 0;

    location / {
        include /config/nginx/proxy.conf;
        include /config/nginx/resolver.conf;
        set $upstream_app nextcloud;
        set $upstream_port 443;
        set $upstream_proto https;
        proxy_pass $upstream_proto://$upstream_app:$upstream_port;

        proxy_max_temp_file_size 1024m;
    }
}


Hello,

I created my account and came visit here because I have the exact same question. I do not want to pollute your thread, but I also need some help.

Sadly I will not be able to tell you how to do it, but I went through all these steps and I guess they are correct. I also tried to add the port into the overwrite.cli.url. Not better :frowning: