The OS I am running is ubuntu 22.04. I’ve set my local dns record to resolve nextcloud. to my home lab’s external-facing IP. The following guides are the ones that I am following:
# Local instance
It is possible due to several reasons that you do not want or cannot open Nextcloud to the public internet. However AIO requires a valid certificate to work correctly. Below is discussed how you can achieve both: Having a valid certificate for Nextcloud and only using it locally.
## 1. The recommended way
The recommended way is the following:
1. Set up your domain correctly to point to your home network
1. Set up a reverse proxy by following the [reverse proxy documentation](./reverse-proxy.md) but only open port 80 (which is needed for the ACME challenge to work - however no real traffic will use this port).
1. Set up a local DNS-server like a pi-hole and configure it to be your local DNS-server for the whole network. Then in the Pi-hole interface, add a custom DNS-record for your domain and overwrite the A-record (and possibly the AAAA-record, too) to point to the private ip-address of your reverse proxy (see https://github.com/nextcloud/all-in-one#how-can-i-access-nextcloud-locally)
1. Enter the ip-address of your local dns-server in the deamon.json file for docker so that you are sure that all docker containers use the correct local dns-server.
1. Now, entering the domain in the AIO-interface should work as expected and should allow you to continue with the setup
## 2. Use the ACME DNS-challenge
You can alternatively use the ACME DNS-challenge to get a valid certificate for Nextcloud. Here is described how to set it up: https://github.com/nextcloud/all-in-one#how-to-get-nextcloud-running-using-the-acme-dns-challenge
## 3. Use Cloudflare
If you do not have any contol over the network, you may think about using Cloudflare Tunnel to get a valid certificate for your Nextcloud. However it will be opened to the public internet then. See https://github.com/nextcloud/all-in-one#how-to-run-nextcloud-behind-a-cloudflare-tunnel how to set this up.
## 4. Buy a certificate and use that
If none of the above ways work for you, you may simply buy a certificate from an issuer for your domain. You then download the certificate onto your server, configure AIO in [reverse proxy mode](./reverse-proxy.md) and use the certificate for your domain in your reverse proxy config.
# Reverse Proxy Documentation
A [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy) is basically a web server that enables computers on the internet to access a service in a [private subnet](https://en.wikipedia.org/wiki/Private_network).
**Please note:** Publishing the AIO interface with a valid certificate to the public internet is **not** the goal of this documentation! Instead, the main goal is to publish Nextcloud with a valid certificate to the public internet which is **not** running inside the mastercontainer but in a different container! If you need a valid certificate for the AIO interface, see [point 5](#5-optional-get-a-valid-certificate-for-the-aio-interface).
In order to run Nextcloud behind a web server or reverse proxy (like Apache, Nginx and else), you need to specify the port that AIO's Apache container shall use, add a specific config to your web server or reverse proxy and modify the startup command a bit. All examples below will use port `11000` as example Apache port which will be exposed on the host. Modify the port to your needings.
**Attention:** The process to run Nextcloud behind a reverse proxy consists of at least steps 1, 2 and 4:
1. **Configure the reverse proxy! See [point 1](#1-add-this-to-your-reverse-proxy-config)**
1. **Use the in this document provided startup command! See [point 2](#2-use-this-startup-command)**
1. Optional: If the reverse proxy is installed on the same host and in the host network, you should limit the apache container to only listen on localhost. See [point 3](#3-limit-the-access-to-the-apache-container)
1. **Open the AIO interface. See [point 4](#4-open-the-aio-interface)**
1. Optional: Get a valid certificate for the AIO interface! See [point 5](#5-optional-get-a-valid-certificate-for-the-aio-interface)
1. Optional: How to debug things? See [point 6](#6-how-to-debug-things)
## 1. Add this to your reverse proxy config
**Please note:** Since the Apache container gets created by the mastercontainer, there is **NO** way to provide custom docker labels or custom environmental variables for the Apache container. So please do not attempt to do this because you will fail! Only the documented way will work!
This file has been truncated. show original
Here is my docker compose file:
version: "3"
services:
nextcloud:
container_name: nextcloud-aio-mastercontainer
image: nextcloud/all-in-one:latest
restart: always
ports:
- 8080:8080
environment:
- APACHE_PORT=11000
- NEXTCLOUD_DATADIR=/etc/nextcloud/data
volumes:
- nextcloud_aio_mastercontainer:/mnt/docker-aio-config
- /var/run/docker.sock:/var/run/docker.sock:ro
nginx:
container_name: nginx
image: nginx:1.21.6
restart: always
ports:
- 80:80
- 443:443
volumes:
# - ./nginx:/etc/nginx
- /etc/letsencrypt:/etc/letsencrypt
volumes:
nextcloud_aio_mastercontainer:
name: nextcloud_aio_mastercontainer
The machine is on a lan, and has a private IP address.
On the nextcloud host, when I ping nextcloud., it resolves to my WAN’s public IP address. On the web gui, for the domain field, I enter nextcloud.. I view the log file for the aio docker container, and see the following:
NOTICE: PHP message: The response of the connection attempt to "https://nextcloud.<redacted>:443" was:
NOTICE: PHP message: Expected was: <redacted>
NOTICE: PHP message: The error message was: SSL certificate problem: self-signed certificate
I’m just not sure where to go from here.
NOTE : It seems there’s a parser messing with some of my text. Wherever you see “nextcloud.”, it should really read as follows:
Hi, do I see correctly that you do not own a domain?
I looked in the aio log files, and didn’t see anything about /var/run/docker.sock
in there.
When I attempt to drop into the caddy container to check #7 I get this:
docker exec -it 710a4beebfcc bash OCI runtime exec failed: exec failed: unable to start container process: exec: "bash": executable file not found in $PATH: unknown