Seafile12专业版,域名加自定义端口访问的部署设置

一、示例域名:

https://my.site.cn:21443

需要开放的端口: 21443,8082,8083

二、硬件:

群晖DS923

三、启用的容器:

seafile,caddy,notification-server,seadoc

四、软件版本:

Seafile Pro Editon 12.0.6

五:域名SSL证书路径:

/volume1/docker/ssl
├── fullchain.cer
└── my.site.cn.key

六、Seafile数据目录结构:

/volume1/docker/seafile-server/

├── notification-data
│ └── logs
├── seadoc-data
├── seafile-caddy
├── seafile-data
├── seafile-elasticsearch
│ └── data
└── seafile-mysql
│ └── db

七、配置文件:

创建目录:

# 创建目录
mkdir -p /volume1/docker/ssl
mkdir -p /volume1/docker/seafile-server/{notification-data/logs,seadoc-data,seafile-caddy,seafile-data,seafile-elasticsearch/data,seafile-mysql/db}

# 设置权限
chmod -R 777 /volume1/docker/seafile-server/seafile-elasticsearch/data
chmod -R 755  /volume1/docker/ssl
chmod -R 755 /volume1/docker/seafile-server/{notification-data,seadoc-data,seafile-caddy,seafile-data,seafile-mysql}

.env,内容修改如下:

COMPOSE_FILE='seafile-server.yml,caddy.yml,notification-server.yml,seadoc.yml'
COMPOSE_PATH_SEPARATOR=','

# Seafile及基本服务

## 镜像
...
## caddy镜像,官方默认镜像没有集成curl,会导致健康检查失败
## 换用lucaslorentz/caddy-docker-proxy:2.9-alpine可以解决
SEAFILE_CADDY_IMAGE=lucaslorentz/caddy-docker-proxy:2.9-alpine

## 持久存储
SEAFILE_VOLUME=/volume1/docker/seafile-server/seafile-data
SEAFILE_MYSQL_VOLUME=/volume1/docker/seafile-server/seafile-mysql/db
SEAFILE_ELASTICSEARCH_VOLUME=/volume1/docker/seafile-server/seafile-elasticsearch/data
SEAFILE_CADDY_VOLUME=/volume1/docker/seafile-server/seafile-caddy
...
## 访问方案
SEAFILE_SERVER_HOSTNAME=my.site.cn:21443
SEAFILE_SERVER_PROTOCOL=https

## 自定义SSL证书路径
PHYSICAL_CERT_PATH=/volume1/docker/ssl
### SSL_CERTIFICATE字段值可以是fullchain.cer或者my.site.cn.crt
SSL_CERTIFICATE=fullchain.cer
SSL_CERTIFICATE_KEY=my.site.cn.key

## 启动参数
TIME_ZONE=Asia/Shanghai
...
# SeaDoc服务
ENABLE_SEADOC=true
SEADOC_VOLUME=/volume1/docker/seafile-server/seadoc-data
SEADOC_SERVER_URL=https://my.site.cn:21443/sdoc-server

# 通知服务器
NOTIFICATION_SERVER_VOLUME=/volume1/docker/seafile-server/notification-data

seafile-server.yml,内容修改如下:

services:
...
seafile:
    ...
    labels:
      ...
      caddy.tls: /ssl/${SSL_CERTIFICATE} /ssl/${SSL_CERTIFICATE_KEY}
    ...

caddy.yml,内容修改如下:

services:

  caddy:
    image: ${SEAFILE_CADDY_IMAGE:-lucaslorentz/caddy-docker-proxy:2.9-alpine}
    ...
    ports:
     # - 80:80
      - 21443:21443
    ...
    volumes:
      ...
      - ${PHYSICAL_CERT_PATH:-/ssl}:/ssl
      ...

seafevents.conf,完成部署之后,可修改下列字段值,仅索引文件名和目录名,修改完之后重启容器:

...
[INDEX FILES]
...
index_office_pdf = false
...

seahub_settings.py,完成部署之后,SERVICE_URL 与 FILE_SERVER_ROOT 应如下所示:

# -*- coding: utf-8 -*-
...
SERVICE_URL = "http://my.site.cn:21443"
...
FILE_SERVER_ROOT = 'https://my.site.cn:21443/seafhttp'
...

seafile.nginx.conf,完成部署之后,开头应如下所示:

# -*- mode: nginx -*-
# Auto generated at 01/08/2025 22:23:30
server {
listen 80;
server_name my.site.cn;
...

执行 sudo docker logs -f seafile,正常日志如下:

*** Running /etc/my_init.d/01_create_data_links.sh...
*** Booting runit daemon...
*** Runit started as PID 19
*** Running /scripts/enterpoint.sh...
2025-01-13 00:02:47 Nginx ready 
2025-01-13 00:02:47 This is an idle script (infinite loop) to keep container running. 
[2025-01-13 00:02:47] Skip running setup-seafile-mysql.py because there is existing seafile-data folder.
[01/13/2025 00:02:47][upgrade]: The container was recreated, start fix the media symlinks
mv: not replacing '/shared/seafile/seahub-data/avatars/default-non-register.jpg'
mv: not replacing '/shared/seafile/seahub-data/avatars/default.png'
mv: not replacing '/shared/seafile/seahub-data/avatars/groups'
[01/13/2025 00:02:47][upgrade]: Done

Starting seafile server, please wait ...
Seafile server started

Done.

Starting seahub at port 8000 ...

Seahub is started

Done.
2 个赞

很不错,但是我觉得家宽的话就没必要用caddy了,直接用seafile里面的nginx就行了

之前seafile11,用内置nginx的方案,出现一个问题是,配置了https协议访问之后,浏览器直接输入my.site.cn:21443,前面不加https://就会出现错误,因为忙,就没有深入研究。现在用caddy就不会出现这个问题了,比较方便。

你没加重定向吧,我也是家里nas,但是加了cnd去端口,如果中间在加一层caddy,那就套娃套的太多了,不过caddy可以自己续签证书,这个很不错

貌似caddy可用阿里dns自己申请和续签,有空尝试下

本着“又不是不能用” 的原则,就没花时间去弄,我的证书是用群晖的任务计划,启动acme.sh容器来自动续期的。相比于之前的版本,现在的配置更傻瓜化一些。

请是文件是用群晖自己的container manager启动,还是用命令行启动?

登录DSM,在网络代理里面把VPN设置好,再打开群晖的ssh。
打开Container Manager-注册表,把.env文件里面涉及的镜像提前下载好,把seafile部署需要的配置文件改好,上传到某个目录里面,比如seafiledeploy,记下这个目录的路径,例如/volume1/docker/seafiledeploy。用电脑登录群晖的ssh,然后
cd volume1/docker/seafiledeploy
sudo docker-compose up -d
就部署了。
查看日志就用
sudo docker logs -f seafile
sudo docker logs -f seafile-caddy
sudo docker logs -f seafile-mysql

谢谢,我还以为Container Manager可以自动加载.env文件呢。