[教程]caddy/docker-compose搭建nextcloud私有云
11月17日更新• caddy • docker • docker compose • nextcloud•教程•阅读:1,866次
写在前面
Caddy未使用docker,方便加别的你懂的
docker-compose,nextcloud官方docker镜像:mysql,nextcloud
原料:
- https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/reverse_proxy_configuration.html
- https://hub.docker.com/_/nextcloud
开始
部署docker
apt update #debian
curl -fsSL https://get.docker.com/ | sh #安装docker
systemctl start docker #启动docker
systemctl enable docker #随系统启动
部署Docker Compose
curl -L https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-'uname -s'-'uname -m' > /usr/local/bin/docker-compose
#也可去github上可以选择你要的新版本
#也可以找到如下对应自己的系统,手工下载
# wget https://github.com/docker/compose/releases/download/v2.12.2/docker-compose-linux-x86_64
# mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
部署nextcloud
# 当前目录,或者找个你自己希望的目录
cd /root
mkdir nextcloud/db nextcloud/nextcloud #两个目录分别放数据库和nextcloud程序
新建docker-compose.yml配置文件
nano nextcloud/docker-compose.yml
贴入如下内容,yml好像不支持#备注,弄完后删除其中的备注信息
version: '2'
volumes:
nextcloud:
db:
services:
db:
image: mariadb:10.5
restart: always
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- /root/nextcloud/db:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD= #mysql root密码
- MYSQL_PASSWORD= #数据表用户密码
- MYSQL_DATABASE=nextcloud #数据表名字
- MYSQL_USER=nextcloud #数据表用户
app:
image: nextcloud
restart: always
ports:
- 8080:80
links:
- db
volumes:
- /root/nextcloud/nextcloud:/var/www/html
environment:
- MYSQL_PASSWORD= #mysql root密码
- MYSQL_DATABASE=nextcloud #数据表用户密码
- MYSQL_USER=nextcloud #数据表名字
- MYSQL_HOST=db #数据表用户
运行docker-compose
docker-compose up -d #运行
docker-compose down #下线
此时已经可以通过ip:8080访问,并web段完成安装nextcloud了
安装Caddy
apt updat
apt install sudo -y
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
systemctl enable caddy
配置Caddy
nano /etc/caddy/Caddyfile
# 删除所有内容或用#注释掉所有
#复制一下内容
{
http_port 80
https_port 443
}
v.你的域名.com {
rewrite /.well-known/carddav /remote.php/dav
rewrite /.well-known/caldav /remote.php/dav
reverse_proxy localhost:8080
reverse_proxy /魔法 localhost:31234
header / {
Strict-Transport-Security "max-age=31536000;includeSubdomains;preload"
}
log {
output file /var/log/caddy/access.log
}
tls [email protected]
}
Caddy常用命令
systemctl start caddy #启动
systemctl status caddy #查看状态
systemctl reload caddy #修改/etc/caddy/Caddyfile后,使用该命令重新导入
配置nextcloud
nano /root/nextcloud/nextcloud/config/config.php
'trusted_domains' =>
array (
0 => '10.10.12.54:8080', #原有的你的Ip信息
1 => 'v.你的域名.com', #加入你自己的域名
………………
…………
……
'installed' => true,
'overwriteprotocol' => 'https', #文件末,加入这句,nextcloud使用tls
cd /root/nextcloud
docker-compose down
docker-compose up -d
使用自己的域名访问,试试。
goodluck!