返回列表 发布新帖

[玩法教程] Docker搭建CLIProxyAPI

2263 5
发表于 2026-4-29 13:03:21 | 查看全部 阅读模式 IP:–江苏–苏州

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
本帖最后由 Shuai 于 2026-4-29 13:05 编辑

本文基于CLIProxyAPI v6.9.41版本,Github地址为 https://github.com/router-for-me/CLIProxyAPI,镜像地址为 https://hub.docker.com/r/eceasy/cli-proxy-api


该项目有更多玩法,本文只赘述部署部分,其他请自行探索

docker目录下新建一个文件夹名字为cpa

cpa中新建一个txt文件,复制以下内容:
  1. # Server host/interface to bind to. Default is empty ("") to bind all interfaces (IPv4 + IPv6).
  2. # Use "127.0.0.1" or "localhost" to restrict access to local machine only.
  3. host: ""
  4. # Server port
  5. port: 8317
  6. # TLS settings for HTTPS. When enabled, the server listens with the provided certificate and key.
  7. tls:
  8.   enable: false
  9.   cert: ""
  10.   key: ""
  11. # Management API settings
  12. remote-management:
  13. # Whether to allow remote (non-localhost) management access.
  14. # When false, only localhost can access management endpoints (a key is still required).
  15.   allow-remote: true
  16. # Management key. If a plaintext value is provided here, it will be hashed on startup.
  17. # All management requests (even from localhost) require this key.
  18. # Leave empty to disable the Management API entirely (404 for all /v0/management routes).
  19.   secret-key: "password"
  20. # Disable the bundled management control panel asset download and HTTP route when true.
  21.   disable-control-panel: false
  22. # GitHub repository for the management control panel. Accepts a repository URL or releases API URL.
  23.   panel-github-repository: "https://github.com/router-for-me/Cli-Proxy-API-Management-Center"
  24. # Authentication directory (supports ~ for home directory)
  25. auth-dir: "~/.cli-proxy-api"
复制代码
其中的secret-key: "password"需要自行配置,配置成你需要的密码

修改完后按如图方式创建cpa项目

image.png

docker-compose:
  1. services:
  2.   cli-proxy-api:
  3.     image: eceasy/cli-proxy-api:latest
  4.     container_name: cli-proxy-api
  5.     ports:
  6.       - "8317:8317"
  7.     volumes:
  8.       - ./config.yaml:/CLIProxyAPI/config.yaml
  9.       - ./auths:/root/.cli-proxy-api
  10.     restart: unless-stopped
复制代码


接下来访问 服务器IP:8317/management.html ,进入后台管理页(如果你修改了端口则替换为你的端口),输入你在前面配置的密码,登录

导入auth.json
image.png
配置好,即可使用
image.png


评论5

COSMOSLv.1 发表于 2026-4-29 14:03:09 | 查看全部 IP:–贵州–遵义
感谢分享,步骤写得很清楚,正好有这个需求,收藏了!port 8317这个默认端口记得确认下别跟其他容器冲突
Shuai楼主Lv.1 发表于 2026-4-29 15:14:19 | 查看全部 IP:–江苏–苏州
imRFoZ 发表于 2026-4-29 14:03
感谢分享,步骤写得很清楚,正好有这个需求,收藏了!port 8317这个默认端口记得确认下别跟其他容器冲突 ...

有没有号池分享下,目前200个蹬没了
vQzH0pLv.1 发表于 2026-5-24 19:47:16 | 查看全部 IP:–海南–海口
本帖最后由 vQzH0p 于 2026-5-24 20:39 编辑

cli-proxy-api  | [2026-05-24 19:35:56] [--------] [error] [main.go:456] failed to load config: failed to read config file: read /CLIProxyAPI/config.yaml: is a directory

大佬,为啥我启动不起来呢?卸载项目,然后把cpa新建的txt文件,文件名改成config.yaml就好了。大佬还有个问题,这docker怎么用我局域网的代理呢?我在搞Codex OAuth,如果直接认证,会提示认证失败,国家不支持,所以我就想在CLIProxyAPI的网络配置里设置代理,譬如http://192.168.x.x:xxxx(我电脑的电脑地址),但是没效果,认证的话会直接提示回调 URL 提交失败: 请更新CLI Proxy API或检查连接
jUHNBOLv.1 发表于 2026-5-25 11:23:33 | 查看全部 IP:–四川–成都
vQzH0p 发表于 2026-5-24 19:47
cli-proxy-api  | [2026-05-24 19:35:56] [--------] [error] [main.go:456] failed to load config: faile ...

Codex OAuth 要开启tun模式
vQzH0pLv.1 发表于 2026-5-27 20:26:08 | 查看全部 IP:–海南–海口
本帖最后由 vQzH0p 于 2026-5-27 20:28 编辑
jUHNBO 发表于 2026-5-25 11:23
Codex OAuth 要开启tun模式

谢谢,不过我后来是把机器的网络模式改成虚拟桥接模式,然后安装CLIProxyAPI的时候,在compose文件里添加
  1.     networks:
  2.       cpa:
  3.         ipv4_address: xxx.xxx.xxx.xxx # 分配在此子网范围内的独立静态IP

  4. networks:
  5.   cpa:
  6.     external: true # 引用步骤 1 中创建的外部网络
复制代码
这样装好的CLIProxyAPI就能单独分配内网IP,也就能用上我本地机器上的代理了。

评论

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Copyright © 2026 绿联NAS私有云社区 版权所有 All Rights Reserved. 粤公网安备44030002002555号| 粤ICP备12028978号
关灯 在本版发帖
联系技术支持
返回顶部
快速回复 返回顶部 返回列表