ERR_TOO_MANY_REDIRECTS after proxying docker nextcloud to example.com/nextcloud

Nextcloud version (eg, 20.0.5): 27.0.0
Operating system and version (eg, Ubuntu 20.04): Debian 12

I have a problem with setting up nextcloud on docker. I use nginx-proxy-manager and this docker-compose for nextcloud:

version: '2'

volumes:
  nextcloud:
  db:

services:
  db:
    image: mariadb
    restart: always
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-file-per-table=1 --skip-innodb-read-only-compressed

    volumes:
      - db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=Bund7zXeVz7YnFknLGcnUjHtk #change this
      - MYSQL_PASSWORD=HFdMe9rn5kf7A8Pqc8v86Pre5 #change this
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  app:
    image: nextcloud
    restart: always
    ports:
      - 8888:80
    links:
      - db
    volumes:
      - nextcloud:/var/www/html
    environment:
      - MYSQL_PASSWORD=HFdMe9rn5kf7A8Pqc8v86Pre5  #change this to match the mysql_password above
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_HOST=db

I also use cloudflare. Currently I have CF proxied A record to example.com and CF proxied CNAME nextcloud record. When nextcloud proxy on nginx-proxy-manager set to example .com (example .com → 192.168.0.100:8888) or nextcloud.example .com (nextcloud.example .com → 192.168.0.100:8888) - everything works fine, but when I want to proxy to example.com/nextcloud (example.com → http:// 192.168.0.100:80 and using custom location /nextcloud → http:// 192.168.0.100:8888) - returns ERR_TOO_MANY_REDIRECTS.
Here’s my proxy config: