Openlist服务器端配置备忘录

5 min read

笔者今天晚上突发奇想想去看一部番,但是身边只有MacBook一台,并未配置Openlist来挂在夸克网盘看番,鉴于手边设备实在太多,且有在iPhone上配置Openlist不便的顾虑,故打算用本人租用的一台阿里云轻量服务器构建远程的Openlist服务。

选择搭建方式

笔者本人所拥有的这台阿里云轻量服务器搭载了CentOS 7.6,且在之前已经配置了Docker, Nginx以及诸多前置服务,为了方便省事,最终选择官方文档所推荐的Docker Compose方法,详见官网的这篇文章。

网络环境配置

选择Docker配置的最大困难在于Docker官方镜像在国内很多地区连接苦难,也是耗费笔者最多时间的步骤,为了减少等待时间,笔者走了包括但不限于尝试手动安装Linux版本、使用官网脚本、配置三方镜像等弯路,最后总结出的解决方法为给服务器配置网络环境。

  1. 首先,ssh连接服务器时套用本地代理
ssh -R your_local_port:127.0.0.1:your_local_port root@your_server_ip

注意将服务器IP和网络端口做替换

  1. 在服务器设置代理
export http_proxy=http://127.0.0.1:your_port
export https_proxy=http://127.0.0.1:your_port

其中your_port和第一部所填端口一致。

  1. 为Docker设置代理

私以为这是关键一步,笔者在这里浪费诸多时间。

# 创建代理目录
mkdir -p /etc/systemd/system/docker.service.d

# 写入配置
cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<EOF
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:your_port"
Environment="HTTPS_PROXY=http://127.0.0.1:your_port"
Environment="NO_PROXY=localhost,127.0.0.1,registry.aliyuncs.com"
EOF

# 重启Docker
systemctl daemon-reload
systemctl restart docker

拉取Docker

建议严格遵循官方步骤,即官网这篇文章的后半部分

  1. 创建docker-compose文件
mkdir -p /opt/openlist
cd /opt/openlist
nano docker-compose.yml
  1. 写入以下内容
# docker-compose.yml
services:
  openlist:
    image: 'openlistteam/openlist:latest'
    container_name: openlist
    user: '0:0' # Please replace `0:0` with the actual user ID and group ID you want to use to run OpenList.
    volumes:
      - './data:/opt/openlist/data'
    ports:
      - '5244:5244'
    environment:
      - UMASK=022
    restart: unless-stopped

control + o后按enter保存,按control + x退出

  1. 运行容器
docker compose pull
docker compose up -d

[Optional] 设置Nginx

这里假设阁下想要将域名openlist.example.com用于访问Openlist服务,需要按照以下步骤执行。

  1. 在域名管理界面添加A记录,子域名填openlist,指向服务器IP
  2. 编辑Nginx文件,创建一个单独的.conf文件以方便管理
nano /etc/nginx/conf.d/openlist.conf
server {
    listen 80;
    server_name openlist.example.com; # <--- 修改这里

    # 如果你之后用 Certbot 申请证书,这里会自动变成 HTTPS 配置
    # 目前先配 HTTP 跑通流程

    location / {
        proxy_pass http://127.0.0.1:5244; # Openlist 默认端口

        # --- 基础头信息 ---
        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;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Port $server_port;

        # --- 关键优化配置 (看番/传文件必加) ---

        # 1. 允许大文件上传 (否则网页端上传大文件会报错)
        client_max_body_size 20000m;

        # 2. 视频拖拽进度条支持 (Range Requests)
        # 这一步对于 Infuse/Web 播放器至关重要
        proxy_set_header Range $http_range;
        proxy_set_header If-Range $http_if_range;

        # 3. 防止重定向问题
        proxy_redirect off;
    }
}
  1. 使用certbot生成SSL证书
certbot --nginx -d openlist.example.com
  1. 重载Nginx服务
nginx -t
systemctl reload nginx

配置注意

不出意外的话,现在访问openlist.example.com即可回到熟悉的Openlist主页,请在添加网盘时使用302重定向,防止播放视频卡顿。

Suggest an edit

Last modified: 21 Dec 2025