I do have another workaround.
Using Traefik v2 Reverse Proxy as docker container connecting to Nextcloud AIO docker
Let me quickly recap the issue, as it took me a while to figure it out:
- Nextcloud AIO will create the Nextcloud containers. It is not possible to add these “child” containers to a dedicated docker network
- Instead, they will expose the used ports to the host.
- Issue: exposed ports are only available to the hosts “localhost” and not to other containers “localhost”
If you want a reverse proxy as descibed in the docs, this reverse proxy must be installed “natively” or on another machine, but can not run as docker container on the same machine.
Reason: A docker container can not reach the host network, it can only expose ports to the host network.
(Exception: a container using the " Host network driver" - but 1. it is not recommended and 2. it is mutually exclusive to using any other “Bridge network”)
It is nevertheless possible to reach the host network form within a docker container via
host.docker.internal - special setup presupposed!
Important Note - this method is “for development purpose only” - for me it is still the most elegant solution.
Add a dynamic traefik configuration to a file (e.g.
nextcloud.yml) - don’t forget to include this to traefik via fiel provider:
certresolver: "<your cert resolver>"
- url: "http://host.docker.internal:11000" # connect to nextcloud via localhost port
In your traefik
docker-compose.yml enable the
extra_hosts - don’t forget to stop and start docker-compose afterwards:
# the following 2 lines are the important part you have to add:
For Nextcloud-AIO container, ensure to set the environment variables:
The port mapping for 80 and 8443 should be removed, then the Nextcloud-AIO is ready to spin up
Finally, start nextcloud-aio, connect to the aio port (default 8080) and afterwards you should be able to add your subdomain, forwarded via traefik.