NextCloud behind Reverse Proxy
Just a simple guide to create a basic NextCloud installation behind an NGINX reverse proxy.
Create and run NextCloud container
docker run \
--detach \
--publish 1337:80 \
--name nextcloud \
nextcloud
Add NGINX site
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name my.host.com;
# ...other options
location / {
# ...other options
proxy_pass http://localhost:1337/;
}
}
Add Reverse Proxy info
### In host
docker exec -ti nextcloud bash
### In container
# Skip the next 3 lines if you are hardcore and want to use 'sed' instead
apt update
apt install -y vim
vim /var/www/html/config/config.php
# Add the following to the CONFIG array in /var/www/html/config/config.php
# More parameters can be found here: https://bit.ly/2ZsNmNK
# 'overwritehost' => 'my.host.com'
# 'overwriteprotocol' => 'https'
service apache2 reload
Extras
- You can could use a plain http configuration for the NGINX site but it’s 2019, you shouldn’t.
- You can use the ’external database’ and ‘persistent data’ recommendations found here for a more advanced installation.