{"id":18136135,"url":"https://github.com/pillarszhang/openvpn-client-xray","last_synced_at":"2025-04-06T16:47:51.391Z","repository":{"id":105546953,"uuid":"484182477","full_name":"PillarsZhang/openvpn-client-xray","owner":"PillarsZhang","description":"Based on Docker and Xray, transform OpenVPN to Socks, HTTP, port forward, etc.","archived":false,"fork":false,"pushed_at":"2022-04-21T19:40:58.000Z","size":8,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-12T22:46:11.913Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PillarsZhang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-04-21T19:39:22.000Z","updated_at":"2023-10-21T20:06:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"e084e612-48a4-4467-af3e-d70a800bc643","html_url":"https://github.com/PillarsZhang/openvpn-client-xray","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PillarsZhang%2Fopenvpn-client-xray","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PillarsZhang%2Fopenvpn-client-xray/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PillarsZhang%2Fopenvpn-client-xray/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PillarsZhang%2Fopenvpn-client-xray/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PillarsZhang","download_url":"https://codeload.github.com/PillarsZhang/openvpn-client-xray/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517918,"owners_count":20951715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-01T14:10:56.050Z","updated_at":"2025-04-06T16:47:51.369Z","avatar_url":"https://github.com/PillarsZhang.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OpenVPN Client Xray\n\n**基于 Docker 和 Xray，转化 OpenVPN 为 Socks、HTTP、端口转发等**\n\n**Based on Docker and Xray, transform OpenVPN to Socks, HTTP, port forward, etc.**\n\n[Docker Hub](https://hub.docker.com/r/pillarszhang/openvpn-client-xray)\n\n![Docker Image Version](https://img.shields.io/docker/v/pillarszhang/openvpn-client-xray)\n![Docker Image Size for amd64](https://flat.badgen.net/docker/size/pillarszhang/openvpn-client-xray/latest/amd64?label=amd64)\n![Docker Image Size for arm64](https://flat.badgen.net/docker/size/pillarszhang/openvpn-client-xray/latest/arm64?label=arm64)\n![Docker Image Size for ppc64le](https://flat.badgen.net/docker/size/pillarszhang/openvpn-client-xray/latest/ppc64le?label=ppc64le)\n![Docker Image Size for s390x](https://flat.badgen.net/docker/size/pillarszhang/openvpn-client-xray/latest/s390x?label=s390x)\n![Docker Image Size for arm/v7](https://flat.badgen.net/docker/size/pillarszhang/openvpn-client-xray/latest/arm/v7?label=arm/v7)\n![Docker Image Size for arm/v7](https://flat.badgen.net/docker/size/pillarszhang/openvpn-client-xray/latest/arm/v6?label=arm/v6)\n\n[Github](https://github.com/PillarsZhang/openvpn-client-xray)\n\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/PillarsZhang/openvpn-client-xray)\n\n## 背景\n\n- [Xray (Project X)](https://xtls.github.io/)：高可定制化的路由系统，满足各类使用需求，充分发挥网络性能。\n- [OpenVPN](https://openvpn.net/)：Secure access and network connectivity reimagined.\n\n将 Xray 和 OpenVPN 运行在同一容器，提供了一些配置模板和启动脚本。\n\n## 开始（Quick Start）\n\n### 配置\n\n当前目录下：\n\n- `config`\n    - `config/openvpn.ovpn` -\u003e OpenVPN 配置文件\n    - `config/xray.json` -\u003e Xray 配置文件 [模板](config/xray.json)\n- `docker-compose.yml` -\u003e 如果使用 docker compose（推荐）[模板](docker-compose.yml)\n\n将 OpenVPN 配置文件重命名并放入 `config/openvpn.ovpn`；\n\n修改 `config/xray.json` 文件，根据需求增删 [`inbounds`](https://xtls.github.io/config/inbound.html#inboundobject) 内的入站连接；\n\n以下两种启动方式将 `config` 目录挂载至容器内的 `/root/config`，并且对应 Xray 配置文件 [模板](config/xray.json) 进行端口映射：14850（端口转发）、14851（Socks 代理）、14852（HTTP 代理）。\n\n### 使用 [docker compose](https://docs.docker.com/compose/cli-command/)（推荐）\n\n**启动**\n```\n# docker compose up\ndocker compose up -d\n```\n\n**日志**\n```\ndocker compose logs\n# docker compose logs -t -f\n```\n\n\u003cdetails\u003e\u003csummary\u003e正常输出（示例）\u003c/summary\u003e\n\u003cp\u003e\n\n```\n\u003e start-openvpn-xray ...\n\u003e Replace '${DOCKER_IP}' to '172.17.0.2' in /root/config/xray.json ...\n\u003c Replace done\n\u003e Launch OpenVPN ...\n\u003e Launch Xray ...\n\u003c Wait OpenVPN or Xray exit ...\n2022-04-21 14:20:16 --cipher is not set. Previous OpenVPN version defaulted to BF-CBC as fallback when cipher negotiation failed in this case. If you need this fallback please add '--data-ciphers-fallback BF-CBC' to your configuration and/or add BF-CBC to --data-ciphers.\n2022-04-21 14:20:16 OpenVPN 2.5.6 x86_64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Mar 24 2022\n2022-04-21 14:20:16 library versions: OpenSSL 1.1.1l  24 Aug 2021, LZO 2.10\nXray 1.5.4 (Xray, Penetrates Everything.) Custom (go1.17.8 linux/amd64)\nA unified platform for anti-censorship.\n2022-04-21 14:20:16 NOTE: the current --script-security setting may allow this configuration to call user-defined scripts\n2022/04/21 14:20:16 [Info] infra/conf/serial: Reading config: /dev/stdin\n2022-04-21 14:20:16 TCP/UDP: Preserving recently used remote address: [AF_INET]*.*.*.*:*\n2022-04-21 14:20:16 UDP link local: (not bound)\n2022-04-21 14:20:16 UDP link remote: [AF_INET]*.*.*.*:*\n2022/04/21 14:20:16 [Warning] core: Xray 1.5.4 started\n2022-04-21 14:20:16 WARNING: 'link-mtu' is used inconsistently, local='link-mtu 1541', remote='link-mtu 1542'\n2022-04-21 14:20:16 WARNING: 'comp-lzo' is present in remote config but missing in local config, remote='comp-lzo'\n2022-04-21 14:20:16 [*.*.*.*] Peer Connection Initiated with [AF_INET]*.*.*.*:*\n2022-04-21 14:20:18 Options error: Unrecognized option or missing or extra parameter(s) in [PUSH-OPTIONS]:1: block-outside-dns (2.5.6)\n2022-04-21 14:20:18 TUN/TAP device tun0 opened\n2022-04-21 14:20:18 /sbin/ip link set dev tun0 up mtu 1500\n2022-04-21 14:20:18 /sbin/ip link set dev tun0 up\n2022-04-21 14:20:18 /sbin/ip addr add dev tun0 local 192.168.255.6 peer 192.168.255.5\n2022-04-21 14:20:18 /etc/openvpn/up.sh tun0 1500 1552 192.168.255.6 192.168.255.5 init\n2022-04-21 14:20:18 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this\n2022-04-21 14:20:18 Initialization Sequence Completed\n```\n\n\u003c/p\u003e\n\u003c/details\u003e\n\n**关闭**\n\n```\ndocker compose down\n```\n\n可选：更新 geo-data（如果需要使用 Xray 路由预定义策略）\n```\ndocker compose run openvpn-client-xray update-geo-data --from-cdn\n```\n\n### 使用 docker run\n\n可以参考 [tool](tool) 下的 PowerShell 脚本。\n\n**启动**\n\n```\ndocker run --rm -it `\n    --mount type=bind,source=$(Get-Location)/config,target=/root/config,readonly `\n    --mount type=volume,source=openvpn-client-xray_xray-asset,target=/usr/share/xray `\n    --device=/dev/net/tun --cap-add=NET_ADMIN `\n    -p 127.0.0.1:14850:14850 `\n    -p 127.0.0.1:14851:14851 `\n    -p 127.0.0.1:14852:14852 `\n    pillarszhang/openvpn-client-xray\n```\n\n可选：更新 geo-data（如果需要使用 Xray 路由预定义策略）\n```\ndocker run --rm -it `\n    --mount type=bind,source=$(Get-Location)/config,target=/root/config,readonly `\n    --mount type=volume,source=openvpn-client-xray_xray-asset,target=/usr/share/xray `\n    pillarszhang/openvpn-client-xray update-geo-data `\n    --from-cdn\n```\n\n## 命令行\n\n默认参数请参考 [docker-compose.yml](docker-compose.yml)\n\n```\npillarszhang/openvpn-client-xray \u003ccommand\u003e [arguments]\n\ncommands:\n    start-openvpn-xray      启动服务\n    update-geo-data         更新 geo-data\n\narguments for start-openvpn-xray:\n    --openvpn-config-file   OpenVPN 配置文件路径\n    --openvpn-args          OpenVPN 启动参数\n    --openvpn-args-append   OpenVPN 启动附加参数（有需要请在此设置）\n    --xray-config-file      Xray 配置文件路径\n    --xray-args             Xray 启动参数\n    --xray-args-append      Xray 启动附加参数（有需要请在此设置）\n    --disable-replace       取消变量替换\n\narguments for update-geo-data:\n    --from-cdn              从 jsDelivr CDN 更新（否则是 Github）\n```\n\n## 进阶\n\n在 OpenVPN 服务端没有配置 `duplicate-cn` 的情况下，单个客户端证书只能产生一个连接。此时将该服务部署于公共服务器上，就能被动实现多用户访问。\n\n在将 Docker 内的端口直接映射到公网前（0.0.0.0:14850:14850），请注意安全问题，使用 Xray 的 VLESS 或 VMESS 或许是更好的选择。\n\n`start-openvpn-xray` 命令自动将 Xray 配置文件中的 `${DOCKER_IP}` 占位符替换为该容器在主机中的 IP， 主要用于 Xray 的 listen 监听端口。这是因为在使用 `0.0.0.0` 监听所有网卡时，处于 OpenVPN 虚拟网段中的其它 IP 也能访问这个端口，有安全隐患（可以使用 `--disable-replace` 取消变量替换）。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpillarszhang%2Fopenvpn-client-xray","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpillarszhang%2Fopenvpn-client-xray","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpillarszhang%2Fopenvpn-client-xray/lists"}