Docker-compose with nginx proxy shows 503 error

Hi, all.

I’m trying to install Nextcloud on Docker, cloning the directory.
When running the containers via docker-compose up -d, however, I encountered 503 Service Temporarily Unavailable error, although I didn’t touch anything from the directory.

How could I run properly?


I’ve added some vital information.

System information:

Nextcloud version (eg, 26.0.1): 27.0.2
Operating system and version (eg, Ubuntu 22.04): Manjaro ARM (rolling release)
Apache or nginx version (eg, Apache 2.4.25): nginx 1.25.2
PHP version (eg, 8.1): 8.2.9
Database (sqlite or MariaDB or Postgres) Postgres
Docker (compose) 24.0.2 (2.19.0)
Snap not used
Is this the first time you’ve seen this error? yes

The issue you are facing:

  • Steps to replicate it:
$ git clone https://github.com/nextcloud/docker
$ mv docker/.examples/docker-compose/with-nginx-proxy/postgres/fpm nextcloud
$ cd nextcloud
$ docker-compose up -d
$ curl 192.168.0.2
<html>
<head><title>503 Service Temporarily Unavailable</title></head>
<body>
<center><h1>503 Service Temporarily Unavailable</h1></center>
<hr><center>nginx</center>
</body>
</html>
  • The output of your Nextcloud log in Admin > Logging:

I can’t say anything because I’m not able to enter Admin webpage.

  • The output of your config.php file in /path/to/nextcloud**
    (use https://.../settings/admin/support which auto-removes identifying information!):
$ docker exec -it nextcloud-app-1 /bin/sh
$ cat config/config.php

config/config.php is empty.

  • for Docker/Podman list environment variables ( run “docker inspect {container name}”)**
$ docker inspect nextcloud-app-1 | jq '.[0].Config.Env'
[
  "POSTGRES_PASSWORD=",
  "POSTGRES_DB=nextcloud",
  "POSTGRES_USER=nextcloud",
  "POSTGRES_HOST=db",
  "REDIS_HOST=redis",
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "PHPIZE_DEPS=autoconf \t\tdpkg-dev dpkg \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkgconf \t\tre2c",
  "PHP_INI_DIR=/usr/local/etc/php",
  "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
  "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
  "PHP_LDFLAGS=-Wl,-O1 -pie",
  "GPG_KEYS=39B641343D8C104B2B146DC3F9C39DC0B9698544 E60913E4DF209907D8E30D96659A97C9CF2A795A 1198C0117593497A5EC5C199286AF1F9897469DC",
  "PHP_VERSION=8.2.9",
  "PHP_URL=https://www.php.net/distributions/php-8.2.9.tar.xz",
  "PHP_ASC_URL=https://www.php.net/distributions/php-8.2.9.tar.xz.asc",
  "PHP_SHA256=1e6cb77f997613864ab3127fbfc6a8c7fdaa89a95e8ed6167617b913b4de4765",
  "PHP_MEMORY_LIMIT=512M",
  "PHP_UPLOAD_LIMIT=512M",
  "NEXTCLOUD_VERSION=27.0.2"
]
$ docker inspect nextcloud-web-1 | jq '.[0].Config.Env'
[
  "LETSENCRYPT_EMAIL=",
  "VIRTUAL_HOST=",
  "LETSENCRYPT_HOST=",
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "NGINX_VERSION=1.25.2",
  "PKG_RELEASE=1",
  "NJS_VERSION=0.8.0"
]
$ docker inspect nextcloud-cron-1 | jq '.[0].Config.Env'
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "PHPIZE_DEPS=autoconf \t\tdpkg-dev dpkg \t\tfile \t\tg++ \t\tgcc \t\tlibc-dev \t\tmake \t\tpkgconf \t\tre2c",
  "PHP_INI_DIR=/usr/local/etc/php",
  "PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
  "PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64",
  "PHP_LDFLAGS=-Wl,-O1 -pie",
  "GPG_KEYS=39B641343D8C104B2B146DC3F9C39DC0B9698544 E60913E4DF209907D8E30D96659A97C9CF2A795A 1198C0117593497A5EC5C199286AF1F9897469DC",
  "PHP_VERSION=8.2.9",
  "PHP_URL=https://www.php.net/distributions/php-8.2.9.tar.xz",
  "PHP_ASC_URL=https://www.php.net/distributions/php-8.2.9.tar.xz.asc",
  "PHP_SHA256=1e6cb77f997613864ab3127fbfc6a8c7fdaa89a95e8ed6167617b913b4de4765",
  "PHP_MEMORY_LIMIT=512M",
  "PHP_UPLOAD_LIMIT=512M",
  "NEXTCLOUD_VERSION=27.0.2"
]
$ docker inspect nextcloud-letsencrypt-companion-1 | jq '.[0].Config.Env'
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/app",
  "COMPANION_VERSION=v2.2.8-14-g9fbd668",
  "DOCKER_HOST=unix:///var/run/docker.sock"
]
$ docker inspect nextcloud-proxy-1 | jq '.[0].Config.Env'
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "NGINX_VERSION=1.25.1",
  "PKG_RELEASE=1",
  "NJS_VERSION=0.7.12",
  "NGINX_PROXY_VERSION=1.3.1-36-g6f0be58",
  "DOCKER_GEN_VERSION=0.10.6",
  "DOCKER_HOST=unix:///tmp/docker.sock"
]
$ docker inspect nextcloud-redis-1 | jq '.[0].Config.Env'
[
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "REDIS_VERSION=7.2.0",
  "REDIS_DOWNLOAD_URL=http://download.redis.io/releases/redis-7.2.0.tar.gz",
  "REDIS_DOWNLOAD_SHA=8b12e242647635b419a0e1833eda02b65bf64e39eb9e509d9db4888fb3124943"
$ docker inspect nextcloud-db-1 | jq '.[0].Config.Env'
[
  "POSTGRES_PASSWORD=",
  "POSTGRES_DB=nextcloud",
  "POSTGRES_USER=nextcloud",
  "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
  "LANG=en_US.utf8",
  "PG_MAJOR=15",
  "PG_VERSION=15.4",
  "PG_SHA256=baec5a4bdc4437336653b6cb5d9ed89be5bd5c0c58b94e0becee0a999e63c8f9",
  "DOCKER_PG_LLVM_DEPS=llvm15-dev \t\tclang15",
  "PGDATA=/var/lib/postgresql/data"
]
]
  • The output of your Apache/nginx/system log in /var/log/____:
  • For Docker/Podman post STDOUT of the container (run docker logs {container name})
$ docker logs nextcloud-web-1
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
$ docker logs nextcloud-app-1
Configuring Redis as session handler
=> Searching for scripts (*.sh) to run, located in the folder: /docker-entrypoint-hooks.d/before-starting
==> but the hook folder "before-starting" is empty, so nothing to do
[30-Aug-2023 00:11:15] NOTICE: fpm is running, pid 1
[30-Aug-2023 00:11:15] NOTICE: ready to handle connections
$ docker logs nextcloud-proxy-1
Info: running nginx-proxy version 1.3.1-36-g6f0be58
Setting up DH Parameters..
Warning: TRUST_DOWNSTREAM_PROXY is not set; defaulting to "true". For security, you should explicitly set TRUST_DOWNSTREAM_PROXY to "false" if there is not a trusted reverse proxy in front of this proxy.
Warning: The default value of TRUST_DOWNSTREAM_PROXY might change to "false" in a future version of nginx-proxy. If you require TRUST_DOWNSTREAM_PROXY to be enabled, explicitly set it to "true".
forego      | starting dockergen.1 on port 5000
forego      | starting nginx.1 on port 5100
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: using the "epoll" event method
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: nginx/1.25.1
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: built by gcc 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4)
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: OS: Linux 6.3.0-1-MANJARO-ARM-ODROID
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: getrlimit(RLIMIT_NOFILE): 1048576:1048576
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: start worker processes
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: start worker process 29
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: start worker process 30
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: start worker process 31
nginx.1     | 2023/08/30 00:11:13 [notice] 23#23: start worker process 32
dockergen.1 | 2023/08/30 00:11:14 Generated '/etc/nginx/conf.d/default.conf' from 6 containers
dockergen.1 | 2023/08/30 00:11:14 Running 'nginx -s reload'
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: signal 1 (SIGHUP) received from 33, reconfiguring
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: reconfiguring
dockergen.1 | 2023/08/30 00:11:15 Watching docker events
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: using the "epoll" event method
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: start worker processes
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: start worker process 36
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: start worker process 37
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: start worker process 38
nginx.1     | 2023/08/30 00:11:14 [notice] 23#23: start worker process 39
nginx.1     | 2023/08/30 00:11:15 [notice] 31#31: gracefully shutting down
nginx.1     | 2023/08/30 00:11:15 [notice] 29#29: gracefully shutting down
nginx.1     | 2023/08/30 00:11:15 [notice] 31#31: exiting
nginx.1     | 2023/08/30 00:11:15 [notice] 29#29: exiting
nginx.1     | 2023/08/30 00:11:15 [notice] 29#29: exit
nginx.1     | 2023/08/30 00:11:15 [notice] 31#31: exit
nginx.1     | 2023/08/30 00:11:15 [notice] 30#30: gracefully shutting down
nginx.1     | 2023/08/30 00:11:15 [notice] 32#32: gracefully shutting down
nginx.1     | 2023/08/30 00:11:15 [notice] 32#32: exiting
nginx.1     | 2023/08/30 00:11:15 [notice] 30#30: exiting
nginx.1     | 2023/08/30 00:11:15 [notice] 32#32: exit
nginx.1     | 2023/08/30 00:11:15 [notice] 30#30: exit
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: signal 17 (SIGCHLD) received from 31
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: worker process 31 exited with code 0
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: worker process 32 exited with code 0
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: signal 29 (SIGIO) received
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: signal 17 (SIGCHLD) received from 30
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: worker process 29 exited with code 0
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: worker process 30 exited with code 0
nginx.1     | 2023/08/30 00:11:15 [notice] 23#23: signal 29 (SIGIO) received
dockergen.1 | 2023/08/30 00:11:16 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
dockergen.1 | 2023/08/30 00:11:16 Received event start for container 1c8dc301de8b
dockergen.1 | 2023/08/30 00:11:16 Contents of /etc/nginx/conf.d/default.conf did not change. Skipping notification 'nginx -s reload'
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 1 (SIGHUP) received from 42, reconfiguring
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: reconfiguring
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: using the "epoll" event method
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: start worker processes
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: start worker process 54
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: start worker process 55
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: start worker process 56
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: start worker process 57
nginx.1     | 2023/08/30 00:11:22 [notice] 36#36: gracefully shutting down
nginx.1     | 2023/08/30 00:11:22 [notice] 37#37: gracefully shutting down
nginx.1     | 2023/08/30 00:11:22 [notice] 36#36: exiting
nginx.1     | 2023/08/30 00:11:22 [notice] 37#37: exiting
nginx.1     | 2023/08/30 00:11:22 [notice] 37#37: exit
nginx.1     | 2023/08/30 00:11:22 [notice] 36#36: exit
nginx.1     | 2023/08/30 00:11:22 [notice] 39#39: gracefully shutting down
nginx.1     | 2023/08/30 00:11:22 [notice] 38#38: gracefully shutting down
nginx.1     | 2023/08/30 00:11:22 [notice] 39#39: exiting
nginx.1     | 2023/08/30 00:11:22 [notice] 38#38: exiting
nginx.1     | 2023/08/30 00:11:22 [notice] 39#39: exit
nginx.1     | 2023/08/30 00:11:22 [notice] 38#38: exit
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 17 (SIGCHLD) received from 39
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: worker process 39 exited with code 0
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 29 (SIGIO) received
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 17 (SIGCHLD) received from 36
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: worker process 36 exited with code 0
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 29 (SIGIO) received
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 17 (SIGCHLD) received from 38
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: worker process 37 exited with code 0
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: worker process 38 exited with code 0
nginx.1     | 2023/08/30 00:11:22 [notice] 23#23: signal 29 (SIGIO) received
nginx.1     | 192.168.0.2 192.168.0.2 - - [30/Aug/2023:00:11:25 +0000] "GET / HTTP/1.1" 503 190 "-" "curl/8.1.2" "-"
  • errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors.

I can’t say anything because every containers have no nextcloud.log file in /var/www directory.

Thanks!

This is currently any issue with the updater being offline outside of Docker, so that might be what you are encountering in this moment. It is in the process of being resolved afaik. A total guess of course.

So do you mean that waiting for the upcoming fix is the best as of now?

Honestly hard to say since you provided no logs or details.

Hi @Ruby,
You are missing the required support template. Please fill this form out and edit into your post.

This will give us the technical info and logs needed to help you! Thanks.

I’ve updated some details.

After modifying the docker-compose.yml file as below, it works fine on port 80 (http).

$ diff docker-compose.yml.orig docker-compose.yml
36c36
<       - VIRTUAL_HOST=
---
>       - VIRTUAL_HOST=nextcloud.local
62a63,64
>     environment:
>       - DEFAULT_HOST=nextcloud.local

In other words, services.web.environment must have VIRTUAL_HOST=nextcloud.local, and services.proxy.environment must have DEFAULT_HOST=nextcloud.local. If environment section is missing, feel free to append it.

And executing docker-compose build and docker-compose up -d, in the order, makes Nextcloud working.

Although this solution is working well on port 80 (http), supporting port 443 (https) requires more steps, but I have no plan to describe these steps. In my opinion, this should be regarded as some different issue, not this.