最近不用Synology架設了,迷上了用VPS架設,原因改天在說吧。
不多說,直接就放上Docker-compose,記得將yourdomain.com改成自已的網域
Docker-compose.yml
version: '3.9'
services:
mariadb:
container_name: Nextcloud-DB
image: mariadb:jammy
security_opt:
- no-new-privileges:true
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW --innodb-read-only-compressed=OFF
volumes:
- './db:/var/lib/mysql'
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- TZ=Asia/Taipei
restart: on-failure:5
redis:
image: redis
container_name: Nextcloud-REDIS
hostname: nextcloudredis
healthcheck:
test: ["CMD-SHELL", "redis-cli ping || exit 1"]
volumes:
- './redis:/data'
environment:
TZ: Asia/Taipei
restart: on-failure:5
nextcloud:
container_name: Nextcloud
ports:
- 8082:80
depends_on:
mariadb:
condition: service_started
redis:
condition: service_healthy
environment:
- REDIS_HOST=nextcloudredis
- NEXTCLOUD_TRUSTED_DOMAINS=yourdomain.com
- TRUSTED_PROXIES=yourdomain.com
- OVERWRITEHOST=yourdomain.com
- OVERWRITEPROTOCOL=https
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=nextcloud
- MYSQL_USER=nextcloud
- MYSQL_HOST=mariadb
healthcheck:
test: curl -f http://localhost:80/ || exit 1
volumes:
- './html:/var/www/html'
- './custom_apps:/var/www/html/custom_apps'
- './config:/var/www/html/config'
- './data:/var/www/html/data'
- './themes:/var/www/html/themes'
image: nextcloud
restart: on-failure:5
cron:
image: nextcloud:apache
container_name: Nextcloud-CRON
restart: always
volumes:
- './config:/var/www/html/config'
- './html:/var/www/html'
- './custom_apps:/var/www/html/custom_apps'
- './data:/var/www/html/data'
entrypoint: /cron.sh
depends_on:
mariadb:
condition: service_started
redis:
condition: service_started
Nginx設定
server {
server_name yourdomain.com;
add_header Strict-Transport-Security "max-age=15768000;preload;";
location / {
proxy_pass http://localhost:8082;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 86400;
}
}
架設完成之後要想辦法搞定成下面這個才行
我的VPS是用Vultr架設的