nextcloud / docker

⛴ Docker image of Nextcloud
https://hub.docker.com/_/nextcloud/
GNU Affero General Public License v3.0
6.09k stars 1.83k forks source link

Possibly Bug: Internal Server Error Using Shared Database Network #704

Closed budimanjojo closed 5 years ago

budimanjojo commented 5 years ago

I tried everything for nearly 10 hours already. Seems like something is broken and I don't know what :cry: This is what I did:

  1. Create database network by doing: docker network create db
  2. Have all my databases and Adminer in that network so I can connect to all of them using Adminer (currently having another service working fine).
  3. Compose a Nextcloud + Traefik, always end up with "Internal Server Error" and the logs show nothing unusual. I tried to use web installer by not passing the username and password, it shows up perfectly, but as soon as I put in the database information and click connect, I'm put in the "Internal Server Error" message again. I tried connecting to the database using Adminer and the database is fine. It's just Nextcloud bug I think? Here's my docker-compose.yml (domain name is not shown of course), everything is the same with the example yml file except the database part. If I don't use external network, then Nextcloud will be successfully installed:
version: '3'

services:
  nextcloud_db:
    image: mariadb
    container_name: nextcloud_db
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    restart: always
    volumes:
      - ./database:/var/lib/mysql
    env_file:
      - config.env
    networks:
      - db

  redis:
    image: redis:alpine
    restart: always

  nextcloud:
    image: nextcloud:apache
    restart: always
    volumes:
      - ./nextcloud:/var/www/html
    env_file:
      - config.env
    depends_on:
      - nextcloud_db
      - redis
    networks:
      - traefik
      - db
    labels:
      - "traefik.enable=true"
      - "traefik.backend=nextcloud"
      - "traefik.frontend.rule=Host:nextcloud.example.com"
      - "traefik.port=80"
      - "traefik.docker.network=traefik_default"
      - "traefik.frontend.redirect.permanent=true"
      - "traefik.frontend.redirect.regex=https://(.*)/.well-known/(card|cal)dav"
      - "traefik.frontend.redirect.replacement=https://$$1/remote.php/dav/"
      - "traefik.frontend.headers.SSLRedirect=true"
      - "traefik.frontend.headers.STSSeconds=315360000"
      - "traefik.frontend.headers.browserXSSFilter=true"
      - "traefik.frontend.headers.contentTypeNosniff=true"
      - "traefik.frontend.headers.forceSTSHeader=true"
      - "traefik.frontend.headers.SSLHost=example.com"
      - "traefik.frontend.headers.STSIncludeSubdomains=true"
      - "treafik.frontend.headers.STSPreload=true"
      - "traefik.frontend.headers.frameDeny=true"

  cron:
    image: nextcloud:apache
    restart: always
    volumes:
      - ./nextcloud:/var/www/html
    entrypoint: /cron.sh
    depends_on:
      - nextcloud_db
      - redis

networks:
  traefik:
    external:
      name: traefik_default
  db:
    external: true

And here's my config.env file (credentials and domain is not shown off course):

MYSQL_ROOT_PASSWORD=password
MYSQL_DATABASE=nextcloud
MYSQL_USER=user
MYSQL_PASSWORD=password
MYSQL_HOST=nextcloud_db
REDIS_HOST=redis
REDIS_PORT=6379
NEXTCLOUD_ADMIN_USER=user
NEXTCLOUD_ADMIN_PASSWORD=password
NEXTCLOUD_TRUSTED_DOMAINS=nextcloud.example.com

Thank you

budimanjojo commented 5 years ago

Just an update to my problem. I managed to find the root cause of this. This is because of the way docker compose works with network. In my compose file, I specified the app to be on traefik and db network, but I didn't include default network which should be the default network all the services are in. So, the app and redis service is not on the same network resulting in "Internal Server Error". I always thought it was the database, never thought that not connecting to redis will cause this. So my fix is simply add default to the network for the nextcloud service like this:

    networks:
      - traefik
      - db
      - default

I think I can close this issue now.