简介

PairDrop 是一个支持跨平台的文件共享工具,它允许用户通过本地网络或互联网轻松地在不同设备之间发送图片、文档或文本。与传统的文件传输方式相比,PairDrop 提供了一个无需设置、无需注册的便捷解决方案,适用于拥有现代网页浏览器的所有设备。

相关链接:

Github地址

PairDrop体验地址

部署

DockerCompose 方式部署

docker-compose.yml 文件内容如下:

version: "3"
services:
    pairdrop:
        image: "lscr.io/linuxserver/pairdrop:latest"
        container_name: pairdrop
        restart: unless-stopped
        environment:
            - PUID=1000 # UID to run the application as
            - PGID=100 # GID to run the application as
            - WS_FALLBACK=false # Set to true to enable websocket fallback if the peer to peer WebRTC connection is not available to the client.
            - RATE_LIMIT=false # Set to true to limit clients to 1000 requests per 5 min.
            - RTC_CONFIG=false # Set to the path of a file that specifies the STUN/TURN servers.
            - DEBUG_MODE=false # Set to true to debug container and peer connections.
            - TZ=Etc/UTC # Time Zone
        ports:
            - "3000:3000" # Web UI

使用compose up命令完成部署:

docker compose up -d

公网反代

添加子域名

在域名注册商那添加用于访问PairDrop的子域名

Nginx 配置证书

在Nginx服务器上添加新子域名的配置证书

sudo certbot --nginx --cert-name [域名] -d [域名] -d [子域名1] -d [子域名2] -d [...]

[可选] 使用 Nginx 配置 HTTP 基本认证

  1. 确保已安装 apache2-utils(或类似工具)以使用 htpasswd 命令

  2. 生成用户名和密码

sudo htpasswd -c /path/to/.htpasswd username

# 替换 /path/to/.htpasswd 为你希望存储密码文件的路径(例如 /etc/nginx/.htpasswd)
# 替换 username 为你想要的用户名
# 行后会提示输入密码并确认,密码将被加密存储在文件中

# 如果需要添加更多用户,重复运行但去掉 -c 参数(-c 会创建新文件覆盖旧文件)
sudo htpasswd /path/to/.htpasswd another_username

添加Nginx配置

server {
    listen 443 ssl;
    server_name pairdrop.xxx; # 替换为用于访问PairDrop的子域名

    ssl_certificate /etc/letsencrypt/live/xxxx.xxx/fullchain.pem;     # 替换为ssl证书fullchain.pem文件路径
    ssl_certificate_key /etc/letsencrypt/live/xxxx.xxx/privkey.pem;   # 替换为ssl证书privkey.pem文件路径

    client_max_body_size 0;  # 允许任意大小的文件上传

    auth_basic "Restricted Access";               # 如果配置了HTTP基本认证,加上
    auth_basic_user_file /etc/nginx/.htpasswd;    # 如果配置了HTTP基本认证,加上

    location / { 
        proxy_pass http://127.0.0.1:8080/; 
        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-Proto $scheme;
        
        # WebSocket 支持
        proxy_http_version 1.1; 
        proxy_set_header Upgrade $http_upgrade; 
        proxy_set_header Connection "upgrade"; 
        proxy_read_timeout 36000s; # 增加超时,防止 WebSocket 断开
    }
}

使用

访问

局域网

浏览器访问PairDrop所在服务器的端口号:

[局域网IP地址]:[端口号]

示例:

192.168.1.202:3000

公网反代

https://[域名]

示例:

https://mysubdomains