Bad Gateway with nextcloud-aio behind traefik

Hello,

I am trying to install nextcloud-aio behind a traefik reverse-proxy using docker-compose. I am following this documentation: https://github.com/nextcloud/all-in-one/blob/main/reverse-proxy.md

I was able to open the AIO interface and enter my domain name there but whenever I try to visit it, I get a Bad Gateway error.

docker-compose.yml

version: '3.3'
      
services:

  traefik:
    image: "traefik:v2.10"
    container_name: "traefik"
    restart: always 
    ports:
      - "80:80"
      - "443:443"
    networks:
      - "web"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - "./letsencrypt:/letsencrypt"
      - "./traefik/traefik.yml:/traefik.yml:ro"
      - "./traefik/conf/nextcloud.yml:/conf/nextcloud.yml"

  nextcloud:
    image: nextcloud/all-in-one:latest
    container_name: nextcloud-aio-mastercontainer
    init: true
    restart: always
    ports:
      - "8080:8080"
    environment:
      - APACHE_PORT=11000
      - APACHE_IP_BINDING=0.0.0.0
      - SKIP_DOMAIN_VALIDATION=true
    networks:
      - web
    volumes:
      - nextcloud_aio_mastercontainer:/mnt/docker-aio-config
      - /var/run/docker.sock:/var/run/docker.sock:ro

networks:
  web:
    external: true

volumes:
  nextcloud_aio_mastercontainer:
    name: nextcloud_aio_mastercontainer

traefik.yml

entryPoints:
  http:
    address: ":80"
  https:
    address: ":443"

certificatesResolvers:
  letsencrypt:
    acme:
      storage: /letsencrypt/acme.json
      email: xxx.xxx@xxx.xxx
      tlschallenge: true

providers:
  file:
    directory: "/conf"
    watch: true

nextcloud.yml

http:
  routers:
    nextcloud:
      rule: "Host(`domain-name.ext`)"
      entrypoints:
        - "https"
      service: nextcloud
      middlewares:
        - nextcloud-chain
      tls:
        certresolver: "letsencrypt"

  services:
    nextcloud:
      loadBalancer:
        servers:
          - url: "http://localhost:11000"

  middlewares:
    nextcloud-secure-headers:
      headers:
        hostsProxyHeaders:
          - "X-Forwarded-Host"
        referrerPolicy: "same-origin"

    https-redirect:
      redirectScheme:
        scheme: https

    nextcloud-chain:
      chain:
        middlewares:
          - https-redirect
          - nextcloud-secure-headers

The nc -z localhost 11000; echo $? command suggested in the documentation returns 0.

I am out of idea to debug the situation, any help is welcomed.

Best regards.

this directive points to ‘traefik container port 11000’ as obviously it’s localhost point of view is used. According to the docs this must be used when “- url: “http://localhost:11000” # Use the host’s IP address if Traefik runs outside the host network

Thank you, I missed this part in the documentation and it fixed the problem.

1 Like