mirror of
https://github.com/lush2020/edgetunnel.git
synced 2026-03-21 17:12:33 +08:00
Merge pull request #13 from zizifn/cloudflared-tunnel
Cloudflared tunnel
This commit is contained in:
5
.github/workflows/main.yml
vendored
5
.github/workflows/main.yml
vendored
@@ -32,8 +32,9 @@ jobs:
|
||||
# docker_build_args: |
|
||||
# HD_UUID
|
||||
env:
|
||||
# 这是为了heroku,注意前缀有个HD,这是为了告诉heroku-deploy,这些变量需要传入到container 中。
|
||||
HD_UUID: ${{ secrets.HEROKU_V2RAY_UUID }} # UUID for v2ray user, 为了安全,一定要放入github action token中
|
||||
# 这是为了heroku,注意前缀有个HD,这是为了告诉heroku-deploy,这些变量需要传入到 container 中。
|
||||
HD_UUID: ${{ secrets.HEROKU_V2RAY_UUID }} # UUID for v2ray user, 为了安全,一定要放入 github action token 中
|
||||
HD_TUNNEL_TOKEN: ${{ secrets.HEROKU_TUNNEL_TOKEN }} # token for cloudflared tunnel
|
||||
NODE_ENV: production
|
||||
SECRET_KEY: ${{ secrets.MY_SECRET_KEY }}
|
||||
stop-start:
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
FROM v2fly/v2fly-core:latest
|
||||
|
||||
RUN wget https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -O /root/cloudflared
|
||||
RUN chmod +x /root/cloudflared
|
||||
ADD startup.sh /startup.sh
|
||||
RUN chmod +x /startup.sh
|
||||
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
SOFTWARE.
|
||||
15
README.md
15
README.md
@@ -17,6 +17,7 @@
|
||||
- 利用 Github action 实现 重新部署/停止/启动。
|
||||
- **支持多app和多账户 重新部署/停止/启动。**
|
||||
- 利用 cloudflare CDN 进行加速。
|
||||
- **利用 [cloudflare tunnel](https://www.cloudflare.com/products/tunnel/) 进行加速。**
|
||||
|
||||
```text
|
||||
项目Dockerfile是基于V2fly 官方镜像制作。仅仅增加生产配置文件的脚本。重新部署就可以更新到最新的v2ray。
|
||||
@@ -38,12 +39,16 @@
|
||||
| Name | Description |
|
||||
| ----------------- | ------------------------------------------ |
|
||||
| APP_NAME | 就是你 heroku 项目的名字 |
|
||||
| EMAIL | heroku 账户的 email |
|
||||
| HEROKU_API_KEY | heroku API key, 在 account 设置下可以找到 |
|
||||
| HEROKU_V2RAY_UUID | V2rayUUID |
|
||||
| EMAIL | heroku 账户的 email |
|
||||
| HEROKU_API_KEY | heroku API key,在 account 设置下可以找到 |
|
||||
| HEROKU_V2RAY_UUID | V2rayUUID |
|
||||
| HEROKU_TUNNEL_TOKEN | **可选** cloudflare tunnel 的 token |
|
||||
|
||||
HEROKU_TUNNEL_TOKEN 是可选项,可以忽略. 详细说明,请查看章节 《建立-cloudflare-tunnel-(可选)》
|
||||
|
||||
> 请务必生成新的 UUID。使用已有的 UUID 会使自己 V2ray 暴露在危险之下。
|
||||
|
||||
|
||||
PowerShell:
|
||||
|
||||
```powershell
|
||||
@@ -120,6 +125,10 @@ addEventListener("fetch", (event) => {
|
||||
为 worker 选择速度更快的 IP。
|
||||
https://github.com/badafans/better-cloudflare-ip
|
||||
|
||||
## 建立 cloudflare tunnel (可选)
|
||||
|
||||
项目集成 cloudflare tunnel, 在配置 Secrets `HEROKU_TUNNEL_TOKEN` 之后生效。具体怎么配置,请查看 [cloudflare tunnel](./cloudflared-tunnel.md)。
|
||||
|
||||
## 使用 Environments 实现 多账户/多app Secrets 管理
|
||||
|
||||
文档介绍: https://docs.github.com/en/actions/deployment/using-environments-for-deployment
|
||||
|
||||
29
cloudflared-tunnel.md
Normal file
29
cloudflared-tunnel.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Cloudflare Tunnel
|
||||
|
||||
## 申请 Cloudflare, 并且开通 https://dash.teams.cloudflare.com/
|
||||
|
||||
虽然免费,但是申请 zero trust 需要绑定信用卡。
|
||||
|
||||
需要一个**域名**,并且绑定到 Cloudflare。
|
||||
|
||||
## Cloudflare tunnels
|
||||
|
||||

|
||||
|
||||
## 保存 Token
|
||||
|
||||
在创建时候,可以在 Tunnels 的页面中找到 Token。
|
||||

|
||||
|
||||
## 添加域名
|
||||
|
||||

|
||||
|
||||
注意事项,
|
||||
|
||||
1. Service 配成自己 heroku 的名字, ***.herokuapp.com
|
||||
|
||||
2. HTTP Host Header
|
||||
把自己 heroku 的名字, ***.herokuapp.com,添加进入,很重要。
|
||||
|
||||
然后把 Token 配置到 Github Action `HEROKU_TUNNEL_TOKEN` 就可以。剩下的配置,运行在 herokuapp 的 Cloudflared 会获取。
|
||||
BIN
readme-data/tunnel-host-name.png
Normal file
BIN
readme-data/tunnel-host-name.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 94 KiB |
BIN
readme-data/tunnel-tokens.png
Normal file
BIN
readme-data/tunnel-tokens.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 54 KiB |
BIN
readme-data/tunnels.png
Normal file
BIN
readme-data/tunnels.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.9 KiB |
@@ -49,4 +49,10 @@ cat << EOF > /etc/v2ray/config.json
|
||||
EOF
|
||||
|
||||
# Run V2Ray
|
||||
if [[ $TUNNEL_TOKEN ]]; then
|
||||
echo 'has tunnel token, run cloudflared tunnel'
|
||||
/usr/bin/v2ray -config /etc/v2ray/config.json & /root/cloudflared tunnel --no-autoupdate run --token $TUNNEL_TOKEN
|
||||
else
|
||||
/usr/bin/v2ray -config /etc/v2ray/config.json
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user