必要条件

  1. Heruku 账号

  2. 科学上网环境

  3. Cloudflare 账号

    注意:所有教程类的文章,阅读的同时都需要考虑它的时效性。如果你部署过程遇到问题或者方法失效可留言讨论

免费且高速!

image-20210704133351782

Prerequisites

  1. Heroku account

  2. A proxy (VPN) environment

  3. Cloudflare account

    Note: for all tutorial-style posts, keep their timeliness in mind. If you run into problems during deployment or the method stops working, feel free to leave a comment to discuss.

Free and fast!

image-20210704133351782

开始部署

  • 科学上网环境也许不是必要条件,主要是因为国内网络打开Heroku有点慢,所以有科学上网环境会使整个过程更加顺利一些。
  • 注册账号的过程不予截图展示,先去注册好账号再来操作。

打开项目

首先,打开 Github项目 地址,点击部署到Heroku紫色按钮。

将项目 fork 到自己的账号下。

修改README.md 文件,将部署链接修改为自己的项目。

image-20210828132802250

修改后提交即可。

接下来,点击部署按钮即可。

image-20210704134010708

对于刚注册的Heroku账户,会弹出服务协议页面,点击接受就好了。正确的页面如下图所示,如果点击接受之后没有出现下面这个界面,可以重新打开GitHub项目点击部署按钮进行尝试。

image-20210704140120049

此处的 APP name 在 Cloudflare 代理中还会用到,小白应该记住这个名字。当然了,这些信息其实都是可以查看的,熟练使用的话不需要刻意记。

生成UUID

  1. 打开 V2rayN 客户端,点击服务器->添加VMess服务器

    image-20210704140339498

  2. 点击生成按钮,记录用户ID并填入部署界面AUUID中。

    image-20210704140610760

部署

点击Deploy app按钮,如下显示即为部署成功。

image-20210704140829818

点击Manage APP,进入管理页面,点击Setting,可以查看APP的详细信息,在域名栏中可以看到自己的项目地址,点击这个地址跳转到部署的伪装网站中,伪装网站默认为 Caddy works!

image-20210704141229664

image-20210704141310012

image-20210704141344808

Start Deployment

  • A proxy environment may not be strictly necessary; the main reason is that opening Heroku from mainland China networks is a bit slow, so having a proxy makes the whole process go more smoothly.
  • I won’t show the account registration process in screenshots; go register your account first, then come back.

Open the Project

First, open the GitHub project page, click the purple Deploy to Heroku button.

Fork the project to your own account.

Modify the README.md file and change the deployment link to your own project.

image-20210828132802250

Commit the changes after editing.

Next, click the deploy button.

image-20210704134010708

For a newly registered Heroku account, a service agreement page will pop up; just click Accept. The correct page is shown below. If this interface doesn’t appear after clicking Accept, reopen the GitHub project and click the deploy button to try again.

image-20210704140120049

The APP name here will also be used in the Cloudflare proxy later, so beginners should remember this name. Of course, all of this info can be looked up anytime, so if you’re experienced you don’t need to memorize it.

Generate a UUID

  1. Open the V2rayN client, click Server -> Add VMess Server

    image-20210704140339498

  2. Click the Generate button, note down the user ID and fill it into the AUUID field on the deployment page.

    image-20210704140610760

Deployment

Click the Deploy app button; what’s shown below means the deployment succeeded.

image-20210704140829818

Click Manage APP to enter the management page, then click Setting to view the APP’s details. In the domain column you can see your project’s address; clicking this address jumps to the deployed camouflage website, whose default is “Caddy works!”

image-20210704141229664

image-20210704141310012

image-20210704141344808

Cloudflare 代理

  1. 登录后点击 Workers

    image-20210704141830314

  2. 点击创建Worker

    image-20210704141927438

  3. 在弹出页面中的脚本填入下面的代码,并按图示步骤操作。

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    const SingleDay = '应用程序名1.herokuapp.com'
    const DoubleDay = '应用程序名2.herokuapp.com'
    addEventListener(
    "fetch",event => {

    let nd = new Date();
    if (nd.getDate()%2) {
    host = SingleDay
    } else {
    host = DoubleDay
    }

    let url=new URL(event.request.url);
    url.hostname=host;
    let request=new Request(url,event.request);
    event. respondWith(
    fetch(request)
    )
    }
    )

    image-20210704142810175

  4. 获取新的代理地址。

    image-20210704143013911

Cloudflare Proxy

  1. After logging in, click Workers

    image-20210704141830314

  2. Click Create Worker

    image-20210704141927438

  3. Paste the following code into the script box on the pop-up page, and follow the steps shown in the screenshots.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    const SingleDay = '应用程序名1.herokuapp.com'
    const DoubleDay = '应用程序名2.herokuapp.com'
    addEventListener(
    "fetch",event => {

    let nd = new Date();
    if (nd.getDate()%2) {
    host = SingleDay
    } else {
    host = DoubleDay
    }

    let url=new URL(event.request.url);
    url.hostname=host;
    let request=new Request(url,event.request);
    event. respondWith(
    fetch(request)
    )
    }
    )

    image-20210704142810175

  4. Get the new proxy address.

    image-20210704143013911

上述代码实际上是对两个应用程序之间做了一个简单的负载均衡处理,单双号使用不同的应用程序上网。

截图中并没有这样处理。

建议使用这种负载均衡的方式运行程序,避免过度使用而造成封号。

具体方式为:

  1. 按上述步骤再部署一个应用程序,需要注意使用相同的UUIDpath!!!
  2. 代码中的 应用程序名1 和 应用程序名2 分别替换成两个不同的名称,点击部署即可。

下面提供一种多个程序做负载均衡的代码。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const Day0 = 'app0.herokuapp.com'
const Day1 = 'app1.herokuapp.com'
const Day2 = 'app2.herokuapp.com'
const Day3 = 'app3.herokuapp.com'
const Day4 = 'app4.herokuapp.com'
addEventListener(
"fetch",event => {

let nd = new Date();
let day = nd.getDate() % 5;
if (day === 0) {
host = Day0
} else if (day === 1) {
host = Day1
} else if (day === 2) {
host = Day2
} else if (day === 3){
host = Day3
} else if (day === 4){
host = Day4
} else {
host = Day1
}

let url=new URL(event.request.url);
url.hostname=host;
let request=new Request(url,event.request);
event.respondWith(
fetch(request)
)
}
)

The code above essentially does simple load balancing between two apps, using different apps on odd/even days.

The screenshots don’t do this.

It’s recommended to run the program with this kind of load balancing to avoid excessive usage leading to an account ban.

The specific approach:

  1. Deploy another app following the steps above, making sure to use the same UUID and path!!!
  2. Replace 应用程序名1 and 应用程序名2 in the code with two different names, then click deploy.

Below is code for load balancing across multiple apps.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const Day0 = 'app0.herokuapp.com'
const Day1 = 'app1.herokuapp.com'
const Day2 = 'app2.herokuapp.com'
const Day3 = 'app3.herokuapp.com'
const Day4 = 'app4.herokuapp.com'
addEventListener(
"fetch",event => {

let nd = new Date();
let day = nd.getDate() % 5;
if (day === 0) {
host = Day0
} else if (day === 1) {
host = Day1
} else if (day === 2) {
host = Day2
} else if (day === 3){
host = Day3
} else if (day === 4){
host = Day4
} else {
host = Day1
}

let url=new URL(event.request.url);
url.hostname=host;
let request=new Request(url,event.request);
event.respondWith(
fetch(request)
)
}
)

客户端节点添加

以v2rayN客户端为例,添加VMess服务器, 信息填写如下图所示。 信息有所更改,注意下方的更正信息。

image-20210704144034141

更正:

  1. 上图中的 9 (path)填写 / 即可。
  2. 上图中的 4 (alterId)填写 64.

速度挺快的,Youtube 1080p 轻松。缺点是不能上 Google 学术。流媒体我没测试,大概率应该也上不去。

建议作为备用节点,别把🐏薅死了,可能像 IBM Cloud 一样核平解决此事。

Adding a Client Node

Using the v2rayN client as an example, add a VMess server, fill in the info as shown below. The info has changed; note the corrections below.

image-20210704144034141

Correction:

  1. For item 9 (path) in the image above, just fill in /.
  2. For item 4 (alterId) in the image above, fill in 64.

It’s quite fast — Youtube 1080p is effortless. The downside: Google Scholar doesn’t work. I haven’t tested streaming, and it probably won’t work either.

Recommended as a backup node. Don’t shear the 🐏 to death, or it might get peacefully nuked just like IBM Cloud.