├── heroku.yml ├── readme-data ├── stop.jpg ├── V2rayN.jpg ├── deploy.jpg ├── start.jpg ├── Environments.png ├── GithubSecrets.gif ├── githubactions.gif ├── herokuapikey.gif ├── EnvironmentsDeploy.png └── EnvironmentsSercet.png ├── Dockerfile ├── app.json ├── LICENSE ├── startup.sh ├── .gitignore ├── .github └── workflows │ └── main.yml └── README.md /heroku.yml: -------------------------------------------------------------------------------- 1 | build: 2 | docker: 3 | web: Dockerfile 4 | -------------------------------------------------------------------------------- /readme-data/stop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/stop.jpg -------------------------------------------------------------------------------- /readme-data/V2rayN.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/V2rayN.jpg -------------------------------------------------------------------------------- /readme-data/deploy.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/deploy.jpg -------------------------------------------------------------------------------- /readme-data/start.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/start.jpg -------------------------------------------------------------------------------- /readme-data/Environments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/Environments.png -------------------------------------------------------------------------------- /readme-data/GithubSecrets.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/GithubSecrets.gif -------------------------------------------------------------------------------- /readme-data/githubactions.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/githubactions.gif -------------------------------------------------------------------------------- /readme-data/herokuapikey.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/herokuapikey.gif -------------------------------------------------------------------------------- /readme-data/EnvironmentsDeploy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/EnvironmentsDeploy.png -------------------------------------------------------------------------------- /readme-data/EnvironmentsSercet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/coko8023/coko-vle/main/readme-data/EnvironmentsSercet.png -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM v2fly/v2fly-core:latest 2 | 3 | ADD startup.sh /startup.sh 4 | RUN chmod +x /startup.sh 5 | 6 | CMD /startup.sh 7 | 8 | 9 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "V2Ray", 3 | "description": "Deploy V2ray on Heroku.", 4 | "keywords": [ 5 | "V2Ray" 6 | ], 7 | "env": { 8 | "UUID": { 9 | "description": "V2Ray UUID", 10 | "value": "ce7ea10b-5b27-49ab-a93d-6b184df9cce9" 11 | } 12 | }, 13 | "website": "https://github.com/zizifn/v2ray-heroku", 14 | "repository": "https://github.com/zizifn/v2ray-heroku", 15 | "stack": "container" 16 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 zizifn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /startup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cat << EOF > /etc/v2ray/config.json 4 | { 5 | "policy": { 6 | "levels": { 7 | "0": { 8 | "handshake": 5, 9 | "connIdle": 300, 10 | "uplinkOnly": 2, 11 | "downlinkOnly": 5, 12 | "statsUserUplink": false, 13 | "statsUserDownlink": false, 14 | "bufferSize": 10240 15 | } 16 | }, 17 | "system": { 18 | "statsInboundUplink": false, 19 | "statsInboundDownlink": false, 20 | "statsOutboundUplink": false, 21 | "statsOutboundDownlink": false 22 | } 23 | }, 24 | "inbounds": [ 25 | { 26 | "port": $PORT, 27 | "protocol": "vless", 28 | "settings": { 29 | "clients": [ 30 | { 31 | "id": "$UUID", 32 | "level": 0 33 | } 34 | ], 35 | "decryption": "none" 36 | }, 37 | "streamSettings": { 38 | "network": "ws", 39 | "security": "none" 40 | } 41 | } 42 | ], 43 | "outbounds": [ 44 | { 45 | "protocol": "freedom" 46 | } 47 | ] 48 | } 49 | EOF 50 | 51 | # Run V2Ray 52 | /usr/bin/v2ray -config /etc/v2ray/config.json 53 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: heroku-deploy-stop-start 2 | 3 | on: 4 | workflow_dispatch: 5 | inputs: 6 | actions: 7 | description: "action: deploy/stop/start" 8 | default: "deploy" 9 | auto-start-stop: 10 | description: 'if this is true, then action will run auto stop on 2:00AM and auto start on 5:00AM beijing time' 11 | default: "true" 12 | required: true 13 | type: boolean 14 | env: 15 | description: "environment: Input the name of Environment. If left blank, the main secrets setting will be used by default." 16 | default: "" 17 | 18 | jobs: 19 | heroku-deploy: 20 | if: ${{ github.event.inputs.actions == 'deploy' || github.event.inputs.actions == ''}} 21 | runs-on: ubuntu-latest 22 | environment: ${{ github.event.inputs.env }} 23 | steps: 24 | - run: echo APP_NAME is ${{secrets.APP_NAME}} 25 | - uses: actions/checkout@v2 26 | - uses: akhileshns/heroku-deploy@v3.6.8 # This is the action 27 | with: 28 | heroku_api_key: ${{secrets.HEROKU_API_KEY}} 29 | heroku_app_name: ${{secrets.APP_NAME}} #Must be unique in Heroku 30 | heroku_email: ${{secrets.EMAIL}} 31 | usedocker: true 32 | # docker_build_args: | 33 | # HD_UUID 34 | env: 35 | # 这是为了heroku,注意前缀有个HD,这是为了告诉heroku-deploy,这些变量需要传入到container 中。 36 | HD_UUID: ${{ secrets.HEROKU_V2RAY_UUID }} # UUID for v2ray user, 为了安全,一定要放入github action token中 37 | NODE_ENV: production 38 | SECRET_KEY: ${{ secrets.MY_SECRET_KEY }} 39 | stop-start: 40 | if: ${{ github.event.inputs.actions == 'start' || github.event.inputs.actions == 'stop' }} 41 | runs-on: ubuntu-latest 42 | environment: ${{ github.event.inputs.env }} 43 | steps: 44 | - uses: actions/checkout@v2 45 | - uses: akhileshns/heroku-deploy@v3.7.8 # This is the action 46 | with: 47 | heroku_api_key: ${{secrets.HEROKU_API_KEY}} 48 | heroku_app_name: ${{secrets.APP_NAME}} #Must be unique in Heroku 49 | heroku_email: ${{secrets.EMAIL}} 50 | justlogin: true 51 | - run: | 52 | echo action is ${{ github.event.inputs.actions }} 53 | if [[ ${{ github.event.inputs.actions }} == 'stop' ]]; then heroku ps:scale web=0 -a ${{secrets.APP_NAME}} && echo "stop"; fi 54 | if [[ ${{ github.event.inputs.actions }} == 'start' ]]; then heroku ps:scale web=1 -a ${{secrets.APP_NAME}} && echo "start"; fi 55 | heroku ps -a ${{secrets.APP_NAME}} 56 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # v2ray-heroku 2 | 3 | > ~~貌似新建的app有些需要科学访问~~,如果需要,请使用cloudflare worker CDN 套一层。 4 | 5 | > 切换到最新的 VLESS 协议。具体客户端配置请看 config 章节。 6 | 7 | > v2ray-heroku 是我的主力 backup,我会日常维护它。加入或者修改一些我认为好的配置。但这一般会导致客户端配置需要些许修改。 不过具体配置都会体现在 [详细 VLESS websocket 客户端配置](#vless-websocket-客户端配置) 8 | 9 | 首先查看别人的 [youtube 教程](https://www.youtube.com/watch?v=xHZyDsFYdvA),了解怎么配置 v2ray-heroku。**本项目使用最新 VLESS 协议,请在客户端配置选择 VLESS**。 10 | [详细 VLESS websocket 客户端配置](#vless-websocket-客户端配置) 。 11 | 12 | 如果你还想自动化你的 heroku,请查看下面的教程。 13 | 14 | 本项目是包含, 15 | 16 | - 一键部署 V2ray 到 heroku。 17 | - 利用 Github action 实现 重新部署/停止/启动。 18 | - **支持多app和多账户 重新部署/停止/启动。** 19 | - 利用 cloudflare CDN 进行加速。 20 | 21 | ```text 22 | 项目Dockerfile是基于V2fly 官方镜像制作。仅仅增加生产配置文件的脚本。重新部署就可以更新到最新的v2ray。 23 | 基于官方镜像,这也是v2fly 推荐的做法。 24 | ``` 25 | 26 | > 保持安全最简单的方式就是,保持软件更新。 27 | 28 | ## 一键部署 29 | 30 | [![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy) 31 | 32 | ## Github Actions 管理 33 | 34 | 请 Fork 本项目到自己的账户下。 Actions 需要以下 Secrets 才能正常工作,这些 Secrets 会被 workflow 中的 [akhileshns/heroku-deploy](https://github.com/AkhileshNS/heroku-deploy) 使用。 35 | 36 | 具体实现细节,请查看 [workflow 配置文件](./.github/workflows/main.yml). 37 | 38 | | Name | Description | 39 | | ----------------- | ------------------------------------------ | 40 | | APP_NAME | 就是你 heroku 项目的名字 | 41 | | EMAIL | heroku 账户的 email | 42 | | HEROKU_API_KEY | heroku API key, 在 account 设置下可以找到 | 43 | | HEROKU_V2RAY_UUID | V2rayUUID | 44 | 45 | > 请务必生成新的 UUID。使用已有的 UUID 会使自己 V2ray 暴露在危险之下。 46 | 47 | PowerShell: 48 | 49 | ```powershell 50 | PS C:\Users\> New-Guid 51 | ``` 52 | 53 | Shell: 54 | 55 | ```bash 56 | xxx@xxx:/mnt/c/Users/$ uuidgen 57 | ``` 58 | 59 | ### Github Secrets 60 | 61 | 路径 62 | 63 | ```text 64 | 项目Setting-->Secrets 65 | ``` 66 | 67 | ![Secrets](./readme-data/GithubSecrets.gif) 68 | 69 | ### Heroku API key 70 | 71 | 路径 72 | 73 | ```text 74 | heroku Account settings-->API key 75 | ``` 76 | 77 | ![Secrets](./readme-data/herokuapikey.gif) 78 | 79 | ### Github Actions 界面 80 | 81 | ```text 82 | Actions 83 | ``` 84 | 85 | ![Actions](./readme-data/githubactions.gif) 86 | 87 | ### 重新部署 88 | 89 | 点击 `Run workflow`, 输入 deploy。 然后就会重新 deploy。 90 | 91 | ![deploy](./readme-data/deploy.jpg) 92 | 93 | ### 停止 94 | 95 | 点击 `Run workflow`, 输入 stop。 然后就会 stop,不在计入小时数。 96 | ![stop](./readme-data/stop.jpg) 97 | 98 | ### 启动 99 | 100 | 点击 `Run workflow`, 输入 start。 然后就会启动。 101 | 102 | ![start](./readme-data/start.jpg) 103 | 104 | 105 | ## 建立 cloudflare worker (可选) 106 | 107 | 如果遇到创建的app在正常网络下不能访问,请尝试这个。 108 | 109 | 可以参考 开头的视频。代码如下。 110 | 111 | ```javascript 112 | addEventListener("fetch", (event) => { 113 | let url = new URL(event.request.url); 114 | url.hostname = "你的heroku的hostname"; 115 | let request = new Request(url, event.request); 116 | event.respondWith(fetch(request)); 117 | }); 118 | ``` 119 | 120 | 为 worker 选择速度更快的 IP。 121 | https://github.com/badafans/better-cloudflare-ip 122 | 123 | ## 使用 Environments 实现 多账户/多app Secrets 管理 124 | 125 | 文档介绍: https://docs.github.com/en/actions/deployment/using-environments-for-deployment 126 | 127 | ### 建立 Environments, 并添加 Secrets 128 | 129 | 1. 创建 Environments 130 | ![Environments](./readme-data/Environments.png) 131 | 2. 添加 Secrets 132 | ![EnvironmentsSercet](./readme-data/EnvironmentsSercet.png) 133 | 134 | ### 输入环境名字 135 | **一定要确保环境名字是对的,要不然就会用主的Secrets。** 136 | ![EnvironmentsDeploy](./readme-data/EnvironmentsDeploy.png) 137 | 138 | ## VLESS websocket 客户端配置 139 | 140 | ### JSON 141 | 142 | ```json 143 | "outbounds": [ 144 | { 145 | "protocol": "vless", 146 | "settings": { 147 | "vnext": [ 148 | { 149 | "address": "***.herokuapp.com", // heroku app URL 或者 cloudflare worker url/ip 150 | "port": 443, 151 | "users": [ 152 | { 153 | "id": "", // 填写你的 UUID 154 | "encryption": "none" 155 | } 156 | ] 157 | } 158 | ] 159 | }, 160 | "streamSettings": { 161 | "network": "ws", 162 | "security": "tls", 163 | "tlsSettings": { 164 | "serverName": "***.herokuapp.com" // heroku app host 或者 cloudflare worker host 165 | } 166 | } 167 | } 168 | ] 169 | ``` 170 | 171 | ### v2rayN 172 | 173 | 换成 [V2rayN](https://github.com/2dust/v2rayN) 174 | 175 | 别人的配置教程参考,https://v2raytech.com/v2rayn-config-tutorial/. 176 | 177 | ![v2rayN](/readme-data/V2rayN.jpg) 178 | --------------------------------------------------------------------------------