Docker: Nexcloud + PHP FPM + Let's Encrypt
Docker 13:09 / 15.07.2021 271
The official Nextcloud image for Docker already includes options to automatically obtain a certificate from Let's Encrypt – to do this, just define environment variables LETSENCRYPT_HOST and LETSENCRYPT_EMAIL in the Docker Compose file. But this is not possible for the PHP-FPM version of the image for obvious reasons. Of course, you can solve everything with the container proxy, for example nginx-proxy, but if you need to get Nextcloud up and running quickly just to get acquainted with its functionality and SSL is a must for most of the functionality, then perhaps a simpler solution (but maybe not quite right).
Here is my solution for raising a fully functional Nextcloud instance on Docker, based on an image with PHP-FPM and with SSL from Let's Encrypt.
This solution is not recommended as a production version!
This is just an example - how you can quickly get a working Nextcloud instance up and running, for testing and discovering functionality, with Docker and image with PHP-FPM and with SSL from Let's Encrypt.
Code repository on GitHub: https://github.com/Icemont/Docker-Nexcloud-FPM-LetsEncrypt
What is required?
First, you need to prepare a domain or subdomain, which will be used for testing, and set it up in DNS "A record" with the IP address of your server or VDS where you will deploy Nextcloud instance. It is assumed that this server already has Docker Engine and Git.
In your server console, enter the command to clone the repository with the files for the solution described:
git clone https://github.com/Icemont/Docker-Nexcloud-FPM-LetsEncrypt.git
After cloning is complete, go to the files folder:
Edit the .env file, changing the configuration to your own (few parameters):
# root password for MySQL server MYSQL_ROOT_PASSWORD=topsecret # Password for the MySQL database user MYSQL_PASSWORD=secret # E-mail address for ACME account registration for Let's Encrypt CERTBOT_EMAIL=[email protected] # Domain for SSL certificate from Let's Encrypt (Your domain or subdomain, for which you have set up A record in DNS DOMAIN_NAME=example.com
Then start building and running the test environment:
docker-compose up -d
Docker Compose builds an image of nginx with SSL and automatically gets a certificate for the domain you specified in the settings, builds all the necessary dependencies and runs a Nextcloud instance for tests. It will also create several Docker Volumes to store data and configurations from containers ( useful for tests).
If in the future you need to rebuild the nginx image with SSL, for example, if something went wrong during the first build, you can do it with the command:
docker-compose up --build -d
Then navigate in your browser to the domain you chose for the tests, and complete the installation and setup as usual.