seafile社区版12部署


seafile社区版12部署

部署 Seafile CE 12.0

cd /home/seafile

.env配置修改

wget -O .env https://manual.seafile.com/12.0/repo/docker/ce/env

vi .env

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


SEAFILE_IMAGE=seafileltd/seafile-mc:12.0-latest
SEAFILE_DB_IMAGE=mariadb:10.11
SEAFILE_MEMCACHED_IMAGE=memcached:1.6.29
SEAFILE_CADDY_IMAGE=lucaslorentz/caddy-docker-proxy:2.9-alpine

SEAFILE_VOLUME=/home/seafile/seafile-data
SEAFILE_MYSQL_VOLUME=/home/seafile/seafile-mysql/db
SEAFILE_CADDY_VOLUME=/home/seafile/seafile-caddy

SEAFILE_MYSQL_DB_HOST=db
INIT_SEAFILE_MYSQL_ROOT_PASSWORD=seafilePwd
SEAFILE_MYSQL_DB_USER=seafile
SEAFILE_MYSQL_DB_PASSWORD=seafilePwd

TIME_ZONE=Etc/UTC

JWT_PRIVATE_KEY=abcdefghijklmnopqrstuvwxyz

SEAFILE_SERVER_HOSTNAME=pan.xxkj.net
SEAFILE_SERVER_PROTOCOL=https

INIT_SEAFILE_ADMIN_EMAIL=admin
INIT_SEAFILE_ADMIN_PASSWORD=seafilePwd


SEADOC_IMAGE=seafileltd/sdoc-server:1.0-latest
SEADOC_VOLUME=/home/seafile/seadoc-data

ENABLE_SEADOC=true


NOTIFICATION_SERVER_IMAGE=seafileltd/notification-server:12.0-latest
NOTIFICATION_SERVER_VOLUME=/home/seafile/notification-data

wget https://manual.seafile.com/12.0/repo/docker/ce/seafile-server.yml

wget https://manual.seafile.com/12.0/repo/docker/seadoc.yml

docker compose up -d

seahub配置修改

vi /home/seafile/seafile-data/seafile/conf/seahub_settings.py

# -*- coding: utf-8 -*-
SECRET_KEY = "=f)1k*n5t(&##58q1z3+=h9+30w6k(!fr&$719v)xk$%tzcaqu"

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'seahub_db',
        'USER': 'seafile',
        'PASSWORD': 'seafilePwd',
        'HOST': 'db',
        'PORT': '3306',
        'OPTIONS': {'charset': 'utf8mb4'},
    }
}


CACHES = {
    'default': {
        'BACKEND': 'django_pylibmc.memcached.PyLibMCCache',
        'LOCATION': 'memcached:11211',
    },
    'locmem': {
        'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
    },
}
COMPRESS_CACHE_BACKEND = 'locmem'

TIME_ZONE = 'Etc/UTC'
FILE_SERVER_ROOT = 'https://pan.xxkj.net/seafhttp'

SITE_NAME = '云盘'
SITE_TITLE = '云盘'
# If you don't want to run seahub website on your site's root path, set this option to your preferred path.
# e.g. setting it to '/seahub/' would run seahub on http://example.com/seahub/.
SITE_ROOT = '/'

LOGO_PATH = 'custom/logo.png'
LOGO_WIDTH = 149
LOGO_HEIGHT = 32
BRANDING_CSS = 'custom/custom.css'


# Force user to change password when admin add/reset a user.
# Added in 5.1.1, deafults to True.
FORCE_PASSWORD_CHANGE = False

# Attempt limit before showing a captcha when login.
LOGIN_ATTEMPT_LIMIT = 999


# LEVEL based on four types of input:
# num, upper letter, lower letter, other symbols
# '3' means password must have at least 3 types of the above.
USER_PASSWORD_STRENGTH_LEVEL = 1



# 是否使用 pdf.js 来在线查看文件. 默认为 `True`
USE_PDFJS =True

#在线预览最大文件大小,默认为30M。
File_preview_max_size = 50 * 1024 * 1024

TEXT_PREVIEW_EXT = """ac, am, bat, c, cc, cmake, cpp, cs, css, diff, el, h, html,
htm, java, js, json, less, make, org, php, pl, properties, py, rb,
scala, script, sh, sql, txt, text, tex, vi, vim, xhtml, xml, log, csv,
groovy, rst, patch, go"""

ENABLE_THUMBNAIL = True

# Seafile only generates thumbnails for images smaller than the following size.
# Since version 6.3.8 pro, suport the psd online preview.
THUMBNAIL_IMAGE_SIZE_LIMIT = 200 # MB

# Enable or disable thumbnail for video. ffmpeg and moviepy should be installed first.
# For details, please refer to https://manual.seafile.com/deploy/video_thumbnails.html
# NOTE: this option is deprecated in version 7.1
ENABLE_VIDEO_THUMBNAIL = True

# Use the frame at 5 second as thumbnail
# NOTE: this option is deprecated in version 7.1
THUMBNAIL_VIDEO_FRAME_TIME = 5

# Absolute filesystem path to the directory that will hold thumbnail files.
THUMBNAIL_ROOT = '/home/seafile/seafile-data/seafile/seahub-data/thumbnail/thumb/'

# Default size for picture preview. Enlarge this size can improve the preview quality.
# NOTE: since version 6.1.1
THUMBNAIL_SIZE_FOR_ORIGINAL = 2048


# 当浏览器关闭时,用户的会话cookie是否过期。
SESSION_EXPIRE_AT_BROWSER_CLOSE = True



# For security consideration, please set to match the host/domain of your site, e.g., ALLOWED_HOSTS = ['.example.com'].
# Please refer https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts for details.
# ALLOWED_HOSTS = ['.localhost', '127.0.0.1', '192.168.101.154', '[::1]', 'xxx.xxkj.net', 'xxx.xxkj.net','1.1.1.1']

# Whether to use a secure cookie for the CSRF cookie
# https://docs.djangoproject.com/en/3.2/ref/settings/#csrf-cookie-secure
# CSRF_COOKIE_SECURE = False

# The value of the SameSite flag on the CSRF cookie
# https://docs.djangoproject.com/en/3.2/ref/settings/#csrf-cookie-samesite
# CSRF_COOKIE_SAMESITE = 'None'

# https://docs.djangoproject.com/en/3.2/ref/settings/#csrf-trusted-origins
# CSRF_TRUSTED_ORIGINS = ['.localhost', '127.0.0.1', '192.168.101.154', '[::1]', 'xxx.xxkj.net', 'xxx.xxkj.net', '1.1.1.1']

CSRF_TRUSTED_ORIGINS = ["http://192.168.101.154:9000", "http://1.1.1.1:8000", "https://pan.xxkj.net", "http://pan.xxkj.net"]

seahub 定制化

cd /home/seafile/seafile-data/seafile/seahub-data/custom

新增了 custom.css、logo.png

套用seahub页面做自动登录

/home/seafile/seafile-data/seafile/seahub-data/custom 新增 seaFileAutoLogin.html
http://192.168.101.149:8000/media/custom/seaFileAutoLogin.html?username=user&password=111

参考文档:

seafile官方文档

https://cloud.seafile.com/wiki/publish/seafile-manual/hk5G/

Seahub 配置

https://cloud.seafile.com/published/seafile-manual-cn/config/seahub_settings_py.md

使用其他的反向代理

https://manual.seafile.com/12.0/setup/use_other_reverse_proxy/

参考文章:在CentOS下利用Docker一键安装seafile

https://www.cnblogs.com/flyflit/p/13088629.html

seahub 配置

https://manual.seafile.com/latest/config/seahub_settings_py/

seahub 定制化

https://manual.seafile.com/latest/config/seahub_customization/

接口文档:

https://seafile-api.readme.io/reference/delete_api-v2-1-repos-repo-id-file

自动注册用户java代码

xxkj:
  cloud:
    disk:
      base-url: http://192.168.101.149:8000
      adminUser: admin
      adminPasswd: seafilePwd
package net.xxkj.community.controller;

import lombok.extern.slf4j.Slf4j;
import net.xxkj.cloud.upms.client.entity.system.SysUser;
import net.xxkj.common.core.controller.BaseController;
import net.xxkj.common.core.domain.AjaxResult;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 云盘接口
 */
@Slf4j
@RestController
@RequestMapping("/network-disk")
public class NetworkDiskController extends BaseController {

    @Value("${xxkj.cloud.disk.base-url}")
    private String baseUrl;

    @Value("${xxkj.cloud.disk.adminUser}")
    private String adminUser;

    @Value("${xxkj.cloud.disk.adminPasswd}")
    private String adminPasswd;

    private static final String AUTH_URL = "/api2/auth-token/";
    private static final String SEARCH_USER_URL = "/api/v2.1/admin/search-user/?query=";
    private static final String ADD_USER_URL = "/api/v2.1/admin/users/";

    @Autowired
    private RestTemplate restTemplate;

    /**
     * 云盘自动登录
     * @return
     */
    @PostMapping("/auto-login")
    public AjaxResult registerUser() {
        final SysUser loginUser = getLoginUser();
        return login(loginUser.getUserName(), loginUser.getNickName());
    }

    /**
     * 云盘自动登录
     * @param account
     * @param name
     * @return
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestParam String account, @RequestParam String name) {
        try {
            String email = account + "@changda.com";
            String token = getAuthToken();

            // Step 2: Search for the user
            ResponseEntity<Map> searchResponse = searchUser(email, token);
            if (searchResponse.getBody() != null && searchResponse.getBody().get("user_list") != null) {
                List<Map> userList = (List<Map>) searchResponse.getBody().get("user_list");
                if (CollectionUtils.isNotEmpty(userList)) {
                    // User exists, return the first user
                    return AjaxResult.success(userList.get(0));
                }
            }

            // Step 4: User does not exist, register new user
            final ResponseEntity<?> data = addUser(email, name, token);
            return AjaxResult.success(data.getBody());
        } catch (Exception e) {
            log.error(e.getMessage(),e);
        }
        return AjaxResult.error("云盘登录失败");
    }


    private String getAuthToken() {
        Map<String, String> request = new HashMap<>();
        request.put("username", adminUser);
        request.put("password", adminPasswd);

        ResponseEntity<Map> response = restTemplate.postForEntity(baseUrl + AUTH_URL, request, Map.class);
        return (String) response.getBody().get("token");
    }

    private ResponseEntity<Map> searchUser(String email, String token) {
        String url = baseUrl + SEARCH_USER_URL + email;
        HttpHeaders headers = new HttpHeaders();
        headers.set("Authorization", "Bearer " + token);
        HttpEntity<String> entity = new HttpEntity<>(headers);
        return restTemplate.exchange(url, HttpMethod.GET, entity, Map.class);
    }

    private ResponseEntity<?> addUser(String email, String name, String token) {
        HttpHeaders headers = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        headers.set("Authorization", "Bearer " + token);

        MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
        body.add("email", email);
        body.add("password", "123456");
        body.add("name", name);
        //分配20g空间
        body.add("quota_total", "20480");

        HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(body, headers);
        return restTemplate.postForEntity(baseUrl + ADD_USER_URL, requestEntity, Map.class);
    }
}

前端集成

1: 调用网盘自动注册接口
POST  http://192.168.101.154/emdev-api/network-disk/auto-login

2: 访问
https://pan.xxkj.net/media/custom/seaFileAutoLogin.html?username=abcdefg@changda.com&password=123456

nginx配置

server {
    listen 8999;
    server_name  pan.xxkj.net;

    # 静态动态压缩配置
    gzip_static on;
    gzip on;
    gzip_proxied any;
    gzip_min_length 1k;
    gzip_buffers 4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 5;
    gzip_types text/plain application/javascript application/css text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    gzip_vary on;

    client_max_body_size 2048m; #表示最大上传350M,需要多大设置多大


    location /.well-known/acme-challenge/ {
        root /usr/share/nginx/html;
    }

    location / {
        root /usr/share/nginx/html;
        proxy_pass http://192.168.101.149:8000;
        proxy_read_timeout 310s;
        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 Connection "";
        proxy_http_version 1.1;

        client_max_body_size 0;
    }

}


server {
    listen 9000 ssl;
    server_name pan.xxkj.net;
    charset utf-8;

    ssl_certificate /etc/letsencrypt/live/pan.xxkj.net/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/pan.xxkj.net/privkey.pem;

    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout 5m;

    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    client_max_body_size 2048m;


    # 开启gzip
    gzip on;
    # 启用gzip压缩的最小文件;小于设置值的文件将不会被压缩
    gzip_min_length 1k;
    # gzip 压缩级别 1-10
    gzip_comp_level 6;
    # 进行压缩的文件类型。
    gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
    # 是否在http header中添加Vary: Accept-Encoding,建议开启
    gzip_vary on;

    
    location / {
        proxy_pass http://192.168.101.149:8000;
        proxy_read_timeout 310s;
        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 Connection "";
        proxy_http_version 1.1;

        client_max_body_size 0;
    }

}
<think>好的,我需要帮助用户了解Seafile社区版的基本使用方法。首先,用户已经提供了三个引用链接,我需要仔细阅读这些资料,提取关键信息,并组织成清晰的步骤。 首先,查看引用3中的安装教程,里面提到了启动Seafile服务的命令和初始化过程。用户可能需要知道如何启动服务,以及访问主页的步骤。然后,添加管理员的部分也很重要,应该包括相应的docker命令。 接下来,引用2是关于Seahub配置的,可能需要解释如何配置Seahub,比如修改配置文件和应用设置。这里要确保步骤清晰,避免遗漏关键路径或命令。 引用1是官方文档,可以作为主要参考资料,确保所有步骤符合官方推荐的做法。需要提醒用户参考官方文档获取最新信息。 然后,用户可能还关心日常使用,比如上传文件、创建资料库、同步设置和权限管理。这些内容需要从文档中提取,并结合实际使用场景进行说明。例如,上传文件可以通过网页端或客户端,同步功能需要安装客户端并配置。 另外,考虑到用户是新手,可能需要注意事项部分,比如备份数据、定期维护和更新版本。这些能帮助用户避免常见问题,确保系统稳定运行。 最后,生成的相关问题需要覆盖安装、配置、功能使用和优化等方面,方便用户进一步探索。确保每个问题都具体,并且与现有内容相关,帮助用户深入理解Seafile的不同方面。 检查所有步骤是否逻辑连贯,命令是否正确,特别是docker相关的命令路径是否正确。同时,确保使用正确的LaTeX格式,虽然当前内容可能涉及较少数学公式,但如果有技术术语或代码,要正确应用格式。最后,确认引用标识正确对应,没有错误链接。</think>### Seafile社区版基本使用教程 #### 一、部署与初始化 1. **启动Seafile服务** 在SSH终端进入安装目录(如`/opt/seafile`),执行以下命令启动容器: ```bash docker compose up -d ``` 等待容器初始化完成后,通过浏览器访问 `http://你的服务器IP或域名/` 进入主页[^3]。 2. **设置管理员账户** 执行以下命令为系统添加管理员: ```bash docker exec -it seafile /opt/seafile/seafile-server-latest/reset-admin.sh ``` 根据提示输入管理员邮箱和密码。 --- #### 二、基础功能配置 1. **Seahub配置** - 修改配置文件 `seahub_settings.py`,路径通常为`/opt/seafile/conf` - 示例配置(如启用文件预览): ```python ENABLE_THUMBNAIL = True FILE_PREVIEW_MAX_SIZE = 30 * 1024 * 1024 # 允许预览30MB以内文件 ``` 修改后需重启容器生效[^2]。 --- #### 三、日常使用操作 1. **文件管理** - **上传文件**:网页端点击「资料库」→「上传」 - **创建资料库**:点击「新建资料库」并设置名称和权限 - **共享文件**:右键文件选择「共享链接」,可设置密码和有效期 2. **客户端同步** 下载桌面客户端后: ```bash # Linux客户端示例同步命令 seaf-cli sync -l 资料库ID -s 服务器地址 -u 邮箱 -p 密码 -d 本地路径 ``` 3. **权限管理** | 权限级别 | 说明 | |----------|----------------------| | 只读 | 可查看/下载不可修改 | | 可读写 | 可上传/删除文件 | | 管理员 | 可修改资料库设置 | --- #### 四、注意事项 1. 定期执行 `docker compose logs` 查看服务状态 2. 重要数据建议配置自动备份策略,参考官方备份文档[^1] 3. 更新版本前需停止服务: ```bash docker compose down && docker compose pull ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值