树莓派seafile+frp

  1. 切换到root用户:su root
  2. 挂载外部硬盘mount /dev/sda5 /cloud,然后查看UUIDsudo blkid,修改vi /etc/fstab文件,在最下面添加UUID=1234567 /cloud ntfs defaults 0 0以开机自动挂载硬盘
  3. 安装seafile到挂载的外部硬盘中,具体安装方法参考官网部署 Seafile 服务器(使用 MySQL/MariaDB)
  4. 公网安装frps,配置如下
    [common]
    bind_port = 9000#指定一个端口
    vhost_http_port = 8080#http访问的端口
    vhost_https_port=443#https访问的端口
  5. 本地安装frpc client,添加相应的配置模块。个人理解:当这两项配置好之后,访问http://xxx.com:8080以及https://xxx.com时,frp会定向到本地(seafile所在的机器)的127.0.0.1:8828
    [common]
    server_addr = 11.11.11.11#frps的公网ip地址
    server_port = 9000#frps的端口
    
    [seafile_http]
    type=http
    local_ip=127.0.0.1
    local_port=8828#该端口为随意指定的一个本地端口
    custom_domains=xxx.com
    
    [seafile_https]
    type=https
    local_ip=127.0.0.1
    local_port=8828
    custom_domains=xxx.com
    
    plugin=https2http
    plugin_local_addr=127.0.0.1:8828#与上述指定的本地端口一致
    plugin_host_header_rewrite=127.0.0.1
    plugin_header_X-From-Where=frp
    plugin_crt_path=/path/xxx.com_public.crt#https证书
    plugin_key_path=/path/xxx.com.key
  6. 添加nginx反向代理,添加/etc/nginx/site-available/seafile.conf文件,并配置如下,删除rm /etc/nginx/site-enabled/default,创建符号链接ln -s /etc/nginx/sites-available/seafile.conf /etc/nginx/sites-enabled/seafile.conf个人理解:当seafile机器接收到刚才的127.0.0.1:8828之后,会反向代理到127.0.0.1:8000,这个就是seafile的端口,当收到127.0.0.1:8828/seafhttp时,会反向代理到127.0.0.1:8082,这个就是seahub的端口。最后的location /media需要填写正确。
    server {
        listen 8828;
        server_name 127.0.0.1;
    
        proxy_set_header X-Forwarded-For $remote_addr;
    
    
        location / {
             proxy_pass         http://127.0.0.1:8000;
             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;
    
             # used for view/edit office file via Office Online Server
             client_max_body_size 0;
    
             access_log      /var/log/nginx/seahub.access.log;
             error_log       /var/log/nginx/seahub.error.log;
        }
    
    
        location /seafhttp {
            rewrite ^/seafhttp(.*)$ $1 break;
            proxy_pass http://127.0.0.1:8082;
            client_max_body_size 0;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_connect_timeout  36000s;
            proxy_read_timeout  36000s;
            proxy_send_timeout  36000s;
            send_timeout  36000s;
            proxy_request_buffering off;
        }
        location /media {
            root /cloud/seafile/seafile-server-latest/seahub;
        }
    }
  7. 打开网页,https://xxx.com,修改系统管理->设置中的SERVICE_URL为https://xxx.com,FILE_SERVER_ROOT为https://xxx.com/seafhttp。

发表评论

电子邮件地址不会被公开。 必填项已用*标注