How to Troubleshoot Intermittent 502 Errors Through a Cloudflare Tunnel
When Cloudflare Tunnel returns an intermittent 502 for your website, the cloudflared connector may have failed to reach your local service on…
When you host Nextcloud on a Linux server, Docker Compose lets you define the containers and settings in a YAML file so you can recreate the stack consistently. If you want a guided setup, bundled services, and a built-in management interface, Nextcloud All-in-One (AIO) is the simpler place to start. If you prefer to pick and maintain the database, web server, and supporting services yourself, the community-maintained nextcloud image is a better fit.
A reverse proxy sits in front of Nextcloud, accepts incoming web traffic, encrypts it with HTTPS, and forwards it to the container. You can put either AIO or the community image behind a reverse proxy, though each one connects to it differently. Depending on which path you pick, you will manage containers, configure the proxy, store data, and install upgrades in different ways.
AIO is Nextcloud’s official installation method. Its mastercontainer, which is the main container that controls the rest of the Nextcloud stack, provides a web interface to guide you through setup, updates, and backups. Pick AIO if you want Nextcloud to manage most of its own services and you are willing to follow its network and domain rules. To control the other containers, the mastercontainer mounts the Docker socket. Even though the mount is marked read-only, AIO still uses it to manage those containers. If you do not want to mount the Docker socket, review AIO’s manual-install option and its limitations.
Volunteers maintain the community Docker image, and they aim it at experienced users. You get direct control over the services around Nextcloud, which also means you have to choose, configure, and maintain them yourself. The Apache variant bundles a web server and serves HTTP on container port 80. The FPM variant runs PHP FastCGI on port 9000, using the FastCGI protocol so a separate web server can hand off PHP work to it. Because FPM does not include a web server, you must pair it with one that supports FastCGI and can read Nextcloud’s static files. Never expose port 9000 as a public web port.
For a normal production server, run a supported external database service instead of SQLite. The Nextcloud installation wizard documentation limits SQLite to small or development instances and strongly discourages using it with sync clients. Before you pick a database version, check the system requirements for the Nextcloud release you plan to run. Supported versions change between releases, so an example tag in a Compose file will eventually go stale.
Install Docker Engine and its Compose plugin, then run docker compose version to confirm the plugin responds. Docker’s Compose plugin instructions assume you already have Docker Engine and the Docker CLI installed. On Linux, follow the package instructions for your distribution; if you install the plugin manually, your system will not update it automatically.
With either deployment, keep Nextcloud’s files and database outside containers that you might replace later. A named volume or a host-mounted directory preserves your data when you recreate a container, though it does not replace an independent backup. The community image keeps Nextcloud files under /var/www/html and stores the database in its own data directory. Keep both outside the containers and back them up together so you can restore them as a matched pair. The community image documentation includes Compose examples with a database, Redis, and named volumes. Treat those examples as a starting point, then check the current database requirements and lock down your database credentials.
Be careful if you mount custom files under /var/www/html. The image documentation warns that the image’s installation or upgrade scripts can overwrite or delete files in that directory unless you list them in upgrade.exclude. Check how upgrades treat those paths before you mount custom files there.
AIO also relies on a named volume for its mastercontainer configuration and built-in backups. Keep the documented nextcloud-aio-mastercontainer container name and nextcloud_aio_mastercontainer:/mnt/docker-aio-config volume name, because AIO depends on those exact names when it runs updates and backups. As the documentation notes, choose any non-default Nextcloud data directory during initial setup.
The community image’s Apache and FPM Compose examples do not encrypt traffic with TLS. Place a reverse proxy in front of either setup so browsers and sync clients connect over HTTPS. With the Apache image, point your proxy at the Nextcloud container’s HTTP service. With the FPM image, put the proxy and the FPM container on the same Docker network, configure the proxy to speak FastCGI and serve Nextcloud’s static files, and leave the FPM port unmapped on the host.
AIO uses a separate reverse-proxy procedure. Your proxy must forward requests to AIO’s managed Apache container on the port you set with APACHE_PORT. The guide uses 11000 as an example, though you can pick another port. Configure the same port in your proxy’s upstream settings so the proxy knows where to send traffic. If your proxy runs inside another container, AIO documents ways to connect them, including sharing a Docker network. When you use APACHE_ADDITIONAL_NETWORK, create that network before you start AIO. Because the right port binding and network settings depend on where your proxy runs, follow the current AIO reverse-proxy guide rather than copying an older example.
Nextcloud also needs to know which proxies it can trust to report a client’s real IP address and request details. Add only the IP addresses or CIDR ranges (blocks of IP addresses) for proxies you control to trusted_proxies. The Nextcloud 35 reverse-proxy manual warns that misconfigured forwarded headers allow clients to spoof their apparent IP address, so set the forwarded-for header to match your proxy software.
In many setups, Nextcloud detects the public host and protocol from the headers your proxy sends. Set overwritehost or overwriteprotocol only if automatic detection fails, or if your network layout prevents the proxy from passing those headers. You can also use overwritecondaddr to restrict an override to requests coming from a proxy. Once everything is running, test HTTPS redirects, client-IP logging, and file uploads. You should also test desktop and mobile sync clients along with CalDAV and CardDAV calendar and contact discovery. Nextcloud’s manual notes that the proxy must handle the redirects used for discovery, and the exact syntax depends on your proxy software and version.
AIO adds a few domain and port rules. It expects its own domain or subdomain rather than a subdirectory, and it redirects visitors to port 443. The management interface runs on port 8080 with a self-signed certificate (a certificate not signed by a trusted certificate authority), so opening it by IP address will trigger a browser warning. When AIO runs behind an external reverse proxy, it does not need the port mappings from its standard no-proxy setup, since the management interface and the public Nextcloud endpoint serve different roles.
AIO shows available updates for its managed containers in its web interface. Before you update, make a backup. Then stop the containers and click the “Start and update containers” action. You update the mastercontainer separately. AIO also documents automated backup options, though you must finish initial setup before running its external backup script. Because the script’s automation flags do not return error codes, verify that each backup actually finished, store an independent copy off the server, and test restoring from it.
To update the community image, pull the new image and recreate the containers while keeping your existing settings and volumes. With Compose, run these documented commands:
docker compose pull
docker compose up -d
Back up the database and Nextcloud files before you run an update. The image documentation requires you to upgrade one major version at a time. If you need to cross several major releases, install each version in sequence instead of jumping straight to the latest tag. Check the community image upgrade instructions before you change any image tags.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com