Docker 安装Seafile,实现个人网盘与文档在线编辑

内容目录

前言

Seafile是开源私有云盘,含有全平台客户端,支持在线文档编辑。

注:上传下载速度取决于最外层服务器带宽

支持Docker安装,官方提供安装docker-compress文档。
《社区版与专业版对比》


Docker-compress

以下docker-compress是在官方文档专业版基础上修改而来,增加onlyoffice模块,用以实现在线文档预览编辑功能。部分内容需要自行修改。可使用Portainer的应用模版安装,也可使用docker-compress命令安装。

version: '2.0'
services:
  db:
    image: mariadb:10.1
    container_name: seafile-mysql
    environment:
      - MYSQL_ROOT_PASSWORD=password  # Requested, set the root's password of MySQL service.
      - MYSQL_LOG_CONSOLE=true
    volumes:
      - /share/public/seafile-mysql/db:/var/lib/mysql  # Requested, specifies the path to MySQL data persistent store.
    networks:
      - seafile-net
  memcached:
    image: memcached:1.5.6
    container_name: seafile-memcached
    entrypoint: memcached -m 256
    networks:
      - seafile-net
  oods:
    image: onlyoffice/documentserver:latest
    container_name: seafile-oods
    networks:
      - seafile-net
    environment:
      - JWT_ENABLED=true
      - JWT_SECRET=Seafile123     ##可以自定义
  seafile:
    image: docker.seafile.top/seafileltd/seafile-pro-mc:latest
    #image: seafileltd/seafile-mc:latest
    container_name: seafile
    ports:
      - "8080:80"
    volumes:
      - /share/public/seafile:/shared   # Requested, specifies the path to Seafile data persistent store.
    environment:
      - DB_HOST=db
      - DB_ROOT_PASSWD=password  # Requested, the value shuold be root's password of MySQL service.
      - TIME_ZONE=Asia/Shanghai # Optional, default is UTC. Should be uncomment and set to your local time zone.
      - SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'
      - SEAFILE_ADMIN_PASSWORD=password    # Specifies Seafile admin password, default is 'asecret'
      - SEAFILE_SERVER_LETSENCRYPT=false   # Whether to use https or not
      - SEAFILE_SERVER_HOSTNAME=seafile.example.com # Specifies your host name if https is enabled
    depends_on:
      - db
      - memcached
    networks:
      - seafile-net
networks:
  seafile-net:

其中

- MYSQL_ROOT_PASSWORD=password
- DB_ROOT_PASSWD=password

以上两个密码需要修改为同一个密码。

- JWT_ENABLED=true
- JWT_SECRET=Seafile123     ##可以自定义

以上俩个为onlyoffice令牌开启信息。需要配置在seahub_settings.py文件中,详情见下方。

- SEAFILE_ADMIN_EMAIL=me@example.com # Specifies Seafile admin user, default is 'me@example.com'
- SEAFILE_ADMIN_PASSWORD=password    # Specifies Seafile admin password, default is 'asecret'
- SEAFILE_SERVER_HOSTNAME=seafile.example.com # Specifies your host

以上信息需修改为自己的信息,分别为用户名、密码、与网站域名。


文档在线编辑onlyoffice配置

安装完成后,需进入到/share/public/seafile/nginx/conf目录下,修改其中文件将下面代码放入server{}上方。

# Required for only office document server
map $http_x_forwarded_proto $the_scheme {
        default $http_x_forwarded_proto;
        "" $scheme;
    }

map $http_x_forwarded_host $the_host {
        default $http_x_forwarded_host;
        "" $host;
    }

map $http_upgrade $proxy_connection {
        default upgrade;
        "" close;
    }

并在server{}增加如下端口转发内容。

location /onlyofficeds/ {
        proxy_pass         http://oods/;

        proxy_http_version 1.1;
        client_max_body_size 100M; # Limit Document size to 100MB
        proxy_read_timeout 3600s;
        proxy_connect_timeout 3600s;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $proxy_connection;

       # THIS ONE IS IMPORTANT ! - Subfolder and NO trailing slash !
        proxy_set_header X-Forwarded-Host $the_host/onlyofficeds;

        proxy_set_header X-Forwarded-Proto $the_scheme;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

        access_log      /var/log/nginx/seafdav.access.log seafileformat;
        error_log       /var/log/nginx/seafdav.error.log;
    }

为实现Seafile文档在线预览编辑功能,需要在/share/public/seafile/seafile/conf/seahub_settings.py中添加如下代码。

ENABLE_ONLYOFFICE = True
VERIFY_ONLYOFFICE_CERTIFICATE = True
ONLYOFFICE_APIJS_URL = 'https://seafile.example.com/onlyofficeds/web-apps/apps/api/documents/api.js'
ONLYOFFICE_FILE_EXTENSION = ('doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx', 'odt', 'fodt', 'odp', 'fodp', 'ods', 'fods')
ONLYOFFICE_EDIT_FILE_EXTENSION = ('docx', 'pptx', 'xlsx')
ONLYOFFICE_JWT_SECRET = 'Seafile123'

WebDav开启

修改文件/share/public/seafile/seafile/conf/seafdav.conf内容,将enabled = false修改为enabled = true。重启容器即可

如此配置完成后,即可实现Seafile个人网盘。

  • 海报
  • 打赏
  • 分享
海报图正在生成中...
分享到...
请选择打赏方式
  • 微信
  • 支付宝

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注