阿里云服务器使用docker搭建私有云seafile

    xiaoxiao2023-10-18  160

    记录下自己搭建的过程,备忘录

    官网的文档移步:https://manual-cn.seafile.com/deploy/deploy_with_docker.html

     

     

    在docker hup中搜索seafile镜像

    如何使用docker,可以在网上找,很多教程说明

    [root@izm5e1quxhnlkaldhhgoihz docker]# docker search seafile INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED docker.io docker.io/jenserat/seafile Container for setting up Seafile with eith... 73 [OK] docker.io docker.io/seafileltd/seafile Seafile server image. 52 docker.io docker.io/m3adow/seafile Seafile container with auto setup 16 [OK] docker.io docker.io/sunx/seafile Seafile server - open source cloud storage... 12 [OK] docker.io docker.io/foxel/seafile Seafile docker image for swift setup 7 [OK]

    官方镜像seafileltd/seafile

    拉取镜像

    [root@izm5e1quxhnlkaldhhgoihz docker]# docker pull docker.io/seafileltd/seafile Using default tag: latest Trying to pull repository docker.io/seafileltd/seafile ... latest: Pulling from docker.io/seafileltd/seafile 1489501ea318: Pull complete c197ac8352c5: Pull complete Digest: sha256:f0d42312c8935973515213677619b3fed877c7276949ac18e01804565a21ba7e Status: Downloaded newer image for docker.io/seafileltd/seafile:latest [root@izm5e1quxhnlkaldhhgoihz docker]# docker images -a REPOSITORY TAG IMAGE ID CREATED SIZE docker.io/seafileltd/seafile latest 68e4dbd7c90d 3 months ago 1.03 GB

     

    创建容器并运行

    docker run -d --name seafile \ -e SEAFILE_SERVER_HOSTNAME=172.31.27.173 \ -e SEAFILE_ADMIN_EMAIL=123456@qq.com \ -e SEAFILE_ADMIN_PASSWORD=123456 \ -v /opt/seafile-data:/shared \ -p 18001:80 \ docker.io/seafileltd/seafile

    --name seafile 指定容器名称seafile

    -e SEAFILE_SERVER_HOSTNAME 镜像内置了nginx,这是配置server_name的,改成自己的域名,局域网写本机ip也行

    -e SEAFILE_ADMIN_EMAIL 管理员账号

    -e SEAFILE_ADMIN_PASSWORD 管理员密码

    -v /opt/seafile-data:/shared 把宿主机的/opt/seafile-data挂载到容器的/shared目录

    -p 18001:80 把宿主机的18001映射到容器的端口80

    这里没有开始ssl安全模式,在后面有另一种方式来配置

     

     

    跟踪日志

    [root@izm5e1quxhnlkaldhhgoihz seafile-data]# docker logs -f seafile --------------------------------- This is your configuration --------------------------------- server name: seafile server ip/domain: 172.31.27.173 seafile data dir: /opt/seafile/seafile-data fileserver port: 8082 database: create new ccnet database: ccnet_db seafile database: seafile_db seahub database: seahub_db database user: seafile Generating ccnet configuration ... Generating seafile configuration ... done Generating seahub configuration ... ---------------------------------------- Now creating seahub database tables ... ---------------------------------------- creating seafile-server-latest symbolic link ... done ----------------------------------------------------------------- Your seafile server configuration has been finished successfully. ----------------------------------------------------------------- run seafile server: ./seafile.sh { start | stop | restart } run seahub server: ./seahub.sh { start <port> | stop | restart <port> } ----------------------------------------------------------------- If you are behind a firewall, remember to allow input/output of these tcp ports: ----------------------------------------------------------------- port of seafile fileserver: 8082 port of seahub: 8000 When problems occur, Refer to https://github.com/haiwen/seafile/wiki for information. [05/25/2019 03:52:32][upgrade]: The container was recreated, running minor-upgrade.sh to fix the media symlinks [05/25/2019 03:52:32][upgrade]: Running script /opt/seafile/seafile-server-6.3.4/upgrade/minor-upgrade.sh [2019-05-25 03:52:32] Updating version stamp ------------------------------------------------------------- This script would do the minor upgrade for you. Press [ENTER] to contiune ------------------------------------------------------------- ------------------------------ migrating avatars ... DONE ------------------------------ updating seafile-server-latest symbolic link to /opt/seafile/seafile-server-6.3.4 ... DONE ------------------------------ [05/25/19 03:52:32] ../common/session.c(132): using config file /opt/seafile/conf/ccnet.conf Starting seafile server, please wait ... Seafile server started Done. Starting seahub at port 8000 ... ---------------------------------------- Successfully created seafile admin ---------------------------------------- Seahub is started Done. May 25 04:17:01 76da06176ca8 CRON[2825]: (root) CMD ( cd / && run-parts --report /etc/cron.hourly)

    从上面日志可以看出内部服务还占用了8000和8082两个端口,这里是用docker部署,只需要映射80端口即可,不用理会其他端口

    查看容器

    [root@izm5e1quxhnlkaldhhgoihz seafile-data]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 76da06176ca8 docker.io/seafileltd/seafile "/sbin/my_init -- ..." About an hour ago Up About an hour 0.0.0.0:18001->80/tcp seafile

    至于状态时间为什么是Up About an hour,因为小伙伴们招呼,一起去吃了个饭:-)

    目录结构

    /shared

    共享卷的挂载点,您可以选择在容器外部存储某些持久性信息.在这个项目中,我们会在外部保存各种日志文件和上传目录。 这使您可以轻松重建容器而不会丢失重要信息。

    /shared/db: mysql服务的数据目录/shared/seafile: Seafile 服务的配置文件以及数据文件/shared/logs: 日志目录 /shared/logs/var-log: 我们将容器内的/var/log挂载到本目录.您可以在shared/logs/var-log/nginx/中找到nginx的日志文件/shared/logs/seafile: Seafile 服务运行产生的日志文件目录.比如您可以在 shared/logs/seafile/seafile.log文件中看到seaf-server的日志 /shared/ssl: 存放证书的目录,默认不存在

     

    愉快的玩耍吧

     

    配置服务端

    入口

    访问宿主机的18001端口

    我这里有域名:http://www.liquanqiang.com:18001

    没有域名就ip也没问题

     

     

    服务url

    登录之后,系统管理,修改两个url

     

    SERVICE_URL :默认是docker容器配置的SEAFILE_SERVER_HOSTNAME:8000 即 172.31.27.173:8000 这里要修改为宿主机的url,如上图

    FILE_SERVER_ROOT:是上传下载模块的url,默认是“SERVICE_URL/seafhttp”,修改为上图结果

     

    桌面客户端

    安装客户端

     

    启动

    初次登录,需要填写云盘网址和帐号密码

     

    同步

    服务端和客户端的双向自动同步

    没啥可说的

    需要注意一点的是,默认第一次只会同步私人资料库

    自己创建的资料库,需要手动触发一次同步,以后就会自动同步

     

     

    二级域名替换一级域名加端口的方式

    配置nginx

    在宿主机的nginx的配置文件中增加如下内容,重新加载配置即可

    nginx -s reload

    server { listen 80; server_name seafile.liquanqiang.com; proxy_set_header X-Forwarded-For $remote_addr; location / { proxy_pass http://172.31.27.173:18001; 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_read_timeout 1200s; client_max_body_size 0; access_log /usr/local/nginx/nginx-1.14.1/logs/seafile.access.log; error_log /usr/local/nginx/nginx-1.14.1/logs/seafile.error.log; } }

    最好在这里开始ssl,证书的方式,安全嘛

     

     

    对应的修改如下

    服务端入口

    http://seafile.liquanqiang.com

    服务端配置url

    SERVICE_URL http://seafile.liquanqiang.com

    FILE_SERVER_ROOThttp://seafile.liquanqiang.com/seafhttp

    桌面客户端

    云盘网址 http://seafile.liquanqiang.com

     

    最新回复(0)