NginX as reverse proxy with "subpath"

Hello,

I created a nextcloud docker container with an own db container with docker-compose. The access should be done via a nginx reverse proxy.

...
services:

  nextcloud-db:
    image: mariadb
    container_name: nextcloud-db
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: unless-stopped
    stdin_open: true
    tty: true
    networks:
      - nextcloud
    volumes:
      - nextcloud-db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=<root password>
      - MYSQL_PASSWORD=<database password>
      - MYSQL_DATABASE=<database>
      - MYSQL_USER=<database user>

  nextcloud-app:
    image: nextcloud
    container_name: nextcloud-app
    restart: unless-stopped
    stdin_open: true
    tty: true
    networks:
      - nextcloud
    ports:
      - 8080:80
    depends_on:
      - nextcloud-db
    volumes:
      - nextcloud-app:/var/www/html
    environment:
      - MYSQL_DATABASE=<database>
      - MYSQL_USER=<datbase user>
      - MYSQL_PASSWORD=<database password>
      - MYSQL_HOST=nextcloud-db
      
  nextcloud-nginx:
    image: nginx
    container_name: nextcloud-nginx
    restart: unless-stopped
    stdin_open: true
    tty: true
    networks:
      - nextcloud
    ports:
      - 80:80
    volumes:
      - nextcloud-nginx:/etc/nginx

The configuration of nginx (container “nextcloud-nginx”): nginx/etc/nginx/conf.d/nextcloud.conf

upstream nextcloud {
    server nextcloud-app:80;
}

server {
    listen       80;
    listen  [::]:80;

    location /nextcloud {
        proxy_pass http://nextcloud;
        proxy_set_header 'Host' $host;
        proxy_set_header 'X-Real-IP' $remote_addr;
        proxy_set_header 'X-Forwarded-For' $proxy_add_x_forwarded_for;
        proxy_set_header 'X-Forwarded-Proto' $scheme;
    }

}

The configuration of nextcloud (container “nextcloud-app”): /var/www/html/config/config.php

...
'trusted_domains' => 
  array (
    0 => '<docker host server name>:8080',
    1 => 'nextcloud-nginx:80', 
  ),
  'trusted_proxies' => 
  array (
    0 => <nextcloud-nginx container ip address>,
  ),
...

My problem is, that nextcloud shows the message “access through untrusted domain” when I access via http://<docker host server name>/nextcloud. What have I done wrong and how can I fix it?

I hope what I have requested is possible.

sure that the port numbers are part of the domain name?

Thanks for the hint! But unfortunately it doesn’t work even if I remove the port and leave only the server name.