Deploy GPT4Free for access to various AI in NAT VPS


Natvps.id – GPT4Free is a library Python which provides access to various Large Language Models (LLM) through various provider. With library this, we can interact with various provider LLMS such as OpenAI, Deepseek, Pollination, and more. GPT4Free also provides web and API clients that can be used through Python.

This article discusses the steps of the GPT4Free deploy in NAT VPS using a docker, along with the Nginx configuration for Reverse-Proxy. This article uses Ubuntu 22.04 as a reference, but you can use other distributions such as Debian and Centos. Make sure the OS used supports the docker.

Port forwarding configuration

Considering we use grout, we need to add 2 Port Forwarding Configuration on the virtualizor panel (or other VPS panels according to the provider), namely Port Forwarding HTTP and HTTPS For the GPT4 -Free domain.

For example, in this article will use a domain ai.tutorial.mdinata.my.id To access GPT4Free. You are free to change the domain according to your choice. Record this port and domain, because we will use it again in the deploy process.

Don’t forget to add DNS Records to go to your NAT VPS public IP, like this:

Install Docker

We will use a docker and compile a docker for men-spread GPT4Free.

First, install curly Using Orders:

apt update && apt install curl -y

Then, run manuscript Automatic installation from the docker by entering:

curl -fsSL get.docker.com | sh

Wait until the installation process is complete.

Spreading GPT4Free

Create a new directory called GPT4Free:

mkdir gpt4free
cd gpt4free/

Create a compose docker configuration using text editor like Nano:

apt install nano -y # Jika belum
nano docker-compose.yml

Fill in the following configuration:

# https;//natvps.id/gpt4free-nat-vps
# References:
#  - 
#  - 

services:
  g4f:
    image: hlohaus789/g4f:latest
    shm_size: 2g
    ports:
      - 8080:8080
      - 7900:7900
    volumes:
      - ./har_and_cookies:/app/har_and_cookies
      - ./generated_media:/app/generated_media

Save the file by pressing CTRL-X, Y, then enter.

Then, make the required directory and set permission His:

mkdir -p ${PWD}/har_and_cookies ${PWD}/generated_media
sudo chown -R 1200:1201 ${PWD}/har_and_cookies ${PWD}/generated_media

Run GPT4Free with Docker Compose:

docker compose up -d

Wait until the action is finished.

Nginx Configuration (Reverse Proxy)

So that we can access the URL through a domain like ai.tutorial.mdinata.my.idwe can use Reverse Proxy Like Nginx.

First, install Nginx through the command:

# Hapus Apache2 dan pendukungnya (biasanya terpasang secara bawaan di VPS OpenVZ)
apt purge apache2* -y

# Install NGINX
apt install nginx -y

Create a new host configuration specifically for GPT4Free:

nano /etc/nginx/sites-available/gpt4free

Then stick the following configuration:

# Konfigurasi NGINX untuk deploy GPT4Free di NAT VPS
# 

server {
    server_name ai.tutorial.mdinata.my.id;
    listen 80;

    location / {
        proxy_pass 
        proxy_set_header Host $host;
        proxy_http_version 1.1;
        proxy_cache off;
        proxy_buffering off;
    }
}

Adjust ai.tutorial.mdinata.my.id with your domain.

Activate the configuration with:

ln -sf /etc/nginx/sites-available/gpt4free /etc/nginx/sites-enabled/gpt4free

# Restart NGINX
systemctl restart nginx

Produce SSL certificate (let’s encryption)

So that our domain can be accessed through HTTPS, we need to make a SSL certificate. We can use a free SSL certificate from Let’s Encrypt through Certbot.

Install Certbot and Nginx plugin use the command:

apt install python3-certbot python3-certbot-nginx

So, produce Certificate through Certbot with the command

certbot --nginx -d ai.tutorial.mdinata.my.id

Change ai.tutorial.mdinata.my.id with your domain.

Happy! Your current domain can be accessed via a safe connection https.

Accessing gpt4free web ui

Open the UI web via your GPT4 -Free domain, for example ai.tutorial.mdinata.my.id

You don’t need to fill in an access token, just click submit to continue. (Reference:

Happy! GPT4Free has been installed and ready for use.



Game Center

Game News

Review Film
Rumus Matematika
Anime Batch
Berita Terkini
Berita Terkini
Berita Terkini
Berita Terkini
review anime

Gaming Center