• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


02 Feb, 2025

Updated at 07 Feb, 2025

Nginx proxy manager can't connect to dockers (502 Bad gateway)

Hi,

I’m quite new to docker and i’m trying to setup a server hosting Nginx proxy manager and a few websites/services.
For example now running nextcloud and wordpress.
I want nginx to redirect cloud.domain.com to nextcloud and domain.com to wordpress. Done this in the past on other machines, but docker is’t working as expected or i’m missing something.
Right now nextcloud is available on the public ip on port 8081 and wordpress on port 2080.
I would expect that if i set the destination to localhost:8081 or localhost:2080 that would do the trick.
As far as i’ve come now, the result is Nginx trying 8081 and 2080 on it’s own container and not the host.
I’ve tried to forward to the hostname: nextcloud:80 (nextcloud container is using port 80 internally) but that gives a bad gateway too.

I suspect i need to do a bit more of networking settings, but i’m a bit lost…

I put the docker compose of nginx and nextcloud down here.

version: '3'
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    ports:
      - '80:80'
      - '81:81'
      - '443:443'
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "nginxpm"
      DB_MYSQL_PASSWORD: ***
      DB_MYSQL_NAME: "nginxpm"
    restart: unless-stopped
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt



  db:
    image: 'jc21/mariadb-aria:latest'
    environment:
      MYSQL_ROOT_PASSWORD: ***
      MYSQL_DATABASE: 'nginxpm'
      MYSQL_USER: 'nginxpm'
      MYSQL_PASSWORD: ***
    restart: unless-stopped
    volumes:
      - ./mysql:/var/lib/mysql
version: '3'

services:
  nextcloud:
    image: nextcloud
    container_name: nextcloud
    restart: unless-stopped
    networks:
      - cloud
    depends_on:
      - nextclouddb
      - redis
    ports:
      - 8081:80
    volumes:
      - ./html:/var/www/html
      - ./custom_apps:/var/www/html/custom_apps
      - ./config:/var/www/html/config
      - ./data:/var/www/html/data
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Amsterdam
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=***
      - MYSQL_HOST=nextclouddb
      - REDIS_HOST=redis

  nextclouddb:
    image: mariadb
    container_name: nextcloud-db
    restart: unless-stopped
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    networks:
      - cloud
    volumes:
      - ./nextclouddb:/var/lib/mysql
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=America/Los_Angeles
      - MYSQL_RANDOM_ROOT_PASSWORD=true
      - MYSQL_PASSWORD=***
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud

  collabora:
    image: collabora/code
    container_name: collabora
    restart: unless-stopped
    networks:
      - cloud
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Amsterdam
      - password=***
      - username=nextcloud
      - domain=all-about.nl
      - extra_params=--o:ssl.enable=true
    ports:
      - 9980:9980

  redis:
    image: redis:alpine
    container_name: redis
    restart: unless-stopped
    volumes:
      - ./redis:/data
    networks:
      - cloud

networks:
  cloud:
    name: cloud
    driver: bridge

2 posts - 2 participants

Read full topic