Creating a Proxy for GPT
In China, OpenAI is banned, so we need to create a proxy to access the OpenAI API.
Setting up an AWS Lightsail server
- Create an Ubuntu 20.04 LTS server on AWS Lightsail.
Installing Node.js on Ubuntu server
Follow the steps below to install Node.js on your Ubuntu server:
- Update the system:
sudo apt update
- Download the Node.js setup script:
cd ~
curl -sL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
- Run the setup script to install Node.js:
sudo bash nodesource_setup.sh
sudo apt install nodejs
Configuring the firewall
To ensure that our proxy server is accessible, we need to configure the firewall. Follow the steps below:
- Allow incoming connections to port 19030:
sudo ufw allow 19030
- Reload the firewall:
sudo ufw reload
Starting and managing the proxy server
To start and manage our proxy server, follow the steps below:
- Stop any existing running instances of the proxy:
forever stop app.js
- Remove the log files of the previous session (if any):
rm -f /home/ubuntu/.forever/forever.log
- Start the proxy server and save the output logs:
forever start -l forever.log -o out.log -e err.log app.js
Checking the firewall status
To verify if the firewall is properly configured and the required ports are open, follow the steps below:
- Check the status of the firewall:
sudo ufw status
- Verify that port 9123 is open:
sudo ufw allow 9123
- Enable the firewall (if not enabled already):
sudo ufw enable
- Reload the firewall:
sudo ufw reload
- Verify the opened ports:
sudo ufw status
By following these steps, you will be able to create a proxy for GPT and access the OpenAI API even in China where it is banned.