Apply for a free domain name at eu.org and create a proxy through cloudfare to access openai without hindrance

I. Introduction

First you need to have a domain name, and secondly the domain name needs to be hosted on cloudfare, so:

  1. Buy domain names directly from cloudfare, it’s convenient and hassle-free!
  2. Find other free domain names, and then host them on cloudfare. With the goal of not spending a penny, here is a top free public domain name application tutorial: eu.org!
    • Advantages: Free, stable, long history, almost no restrictions, NS can be changed!
    • Disadvantages: The application waiting time is long, it can range from 1 to 30 days. Mine was received in 11 days!

2. Apply for the eu.org domain name

1. Click [here](:/ to register your account, fill in the information as shown below, and then click create

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-NXCvlBGe-1684585110935) (null)]

2. If the creation is successful, you will receive a verification email in your mailbox (please check the spam mailbox and move the website out so that you can receive review notifications in time later). The email contains your login name and verification link. Click the link to verify.

verify

3. Click Validate in the picture below to verify, and then log in!

Verify click

4. Click new domain to register the domain name and fill in the information as shown below:

domain name

Notice:

  • The domain name must include the suffix eu.org

  • Fill in the name servers with cloudfare, or other values. It can be modified after successful registration.

    image-20230520151651564

    yichun.ns.cloudflare.com
    demi.ns.cloudflare.com
    

5. After clicking submit, you will be prompted if the domain name already exists. Just modify it and submit it again. If successful, it will be as shown below.down

down

6. Next, wait for the email to be approved:

examination passed

2. Set up cloudfare worker

This part is referenced here : https://github.com/noobnooc/noobnooc/discussions/9, modified, thanks to the original author for providing the tutorial!

1. Host domain name to cloudfare

The first is to host the domain name on clodfare, enter cloufare : https://dash.cloudflare.com/, register and click website.

image

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-NXCvlBGe-1684585110935) (null)]

Fill in the eu.org domain name you applied for. If the name server filled in when applying for the domain name in the previous step is cloudfare, it will be easy! If you use other dns, you will be prompted to modify ns first, find your domain name on eu.org, click on the domain name, then click on nameservers, and change it to the namesever that cloudfare prompts you to set!

Modify ns

2. Create a new Cloudflare Worker

After logging in to Cloudflare's management interface, click the "Workers" option in the sidebar, and then click "Create a Service" to create a Worker.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-yt1iwGGZ-1684585110426) (null)]

Then enter "Service name" in the creation interface and click the "Create Service" button to create a new Worker. Ignore the "Select a starter" item for now.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-D0lLEf6f-1684585110949) (null)]

At this point, Cloudflare's Worker has been created. Let's start modifying the Worker code so that it can proxy OpenAI's API.

In the Worker management interface, click the "Quick Edit" button in the upper right corner to edit the code of the Worker.

image

In the code editor on the left, delete any existing code, then copy and paste the following into the code editor:

export default {
  async fetch(request) {
    const url = new URL(request.url);
    url.host = 'api.openai.com';
    return fetch(url, { headers: request.headers, method: request.method, body: request.body });
  },
};

Finally, click the "Save and deploy" button in the upper right corner of the editor to deploy the code, and continue to select "Save and deploy" in the pop-up dialog box to confirm the deployment.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-ycBlKqPJ-1684585110416) (null)]

3. Bind domain name

In the management interface of Cloudflare Workers, click the "Triggers" tab, and then click the "Add Custom Domain" button in "Custom Domians" to bind the domain name.

[The external link image transfer failed. The source site may have an anti-leeching mechanism. It is recommended to save the image and upload it directly (img-6C5ojpgU-1684585110439) (null)]

This completes all steps. After waiting for a while, you should be able to replace OpenAI's API address with your own domain name, that is, replace the official API address https://api.openai.com/v1/with your own domain name https://xxx.eu.org/v1/ . For other parameters, refer to the official example.

For the chatgpt-on-wechat project currently in use, add a line of configuration to the config.json file:

"open_ai_api_base": "https://xxxx.eu.org/v1",

After the above is completed, domestic servers no longer need to configure proxy software! Cloudflare has a free request quota of 100,000 times per day, which is basically enough for light use!

For more information, please visit my personal blog : https://www.wangpc.cc/

Guess you like

Origin blog.csdn.net/vision666/article/details/130785392