mu_cat

mu_cat

github

Curve rescue uses GPT4.

Completely solve the disgusting error message "something went wrong". How can my esteemed GPT4 user suffer from this injustice!

Required#

docker

pandora

nginx proxy manager

pake

Prerequisites#

A server that can access GPT, I use one in Japan, with warp ipv6 unlocked GPT (optional, you can also use online deployment platform vercel)

Domain name resolved to the server

OpenAI account

Basic knowledge of Linux command line operations

Getting Started#

Unlock GPT on the server with warp ipv6#

Refer to Yongge's script

Choose option 1 to install warp-go

Then choose option 2 to install/switch to WARP single-stack IPV6

image-20230426011250748

Install Docker and Docker Compose on the server#

Almost all servers should have it! My Linux system is Ubuntu, and the following instructions are for Ubuntu. The commands may vary for different Linux versions, so please Google accordingly.

Uninstall old versions#

sudo apt-get remove docker \
               docker-engine \
               docker.io

Install using APT#

sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release

Install Docker#

sudo apt-get install docker.io

Install Docker Compose#

curl -L "https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

Install Nginx Proxy Manager#

Create a new folder "npm" to store data#

cd /root
mkdir npm
cd npm

Edit the docker-compose.yml file#

vim docker-compose.yml
version: "3"
services:
  app:
    image: 'jc21/nginx-proxy-manager:latest'
    restart: unless-stopped
    ports:
      - '80:80' # Public HTTP Port
      - '443:443' # Public HTTPS Port
      - '81:81' # Admin Web Port
    environment:
      DB_MYSQL_HOST: "db"
      DB_MYSQL_PORT: 3306
      DB_MYSQL_USER: "npm"
      DB_MYSQL_PASSWORD: "npm"
      DB_MYSQL_NAME: "npm"
    volumes:
      - ./data:/data
      - ./letsencrypt:/etc/letsencrypt
    depends_on:
      - db

  db:
    image: 'jc21/mariadb-aria:latest'
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: 'npm'
      MYSQL_DATABASE: 'npm'
      MYSQL_USER: 'npm'
      MYSQL_PASSWORD: 'npm'
    volumes:
      - ./data/mysql:/var/lib/mysql

Run the container#

docker-compose up -d 

Access the npm web panel#

Remember to enable the server's hardware firewall (in the server's control panel) and the server's software firewall (e.g., ufw for Ubuntu).

The npm web page can be accessed at your server's IP address followed by :81.

You will be prompted to set a username and password.

The default username is [email protected] and the default password is changeme.

For more details on npm, you can refer to this article. I learned a lot of Linux basics from his tutorials.

Tutorial

Install Pandora#

Here we demonstrate a method of hardcoding the access token in the environment variables. I'm lazy and don't want to enter it every time, so I just hardcode it. Later, we will use npm's access list to prevent abuse.

How to get the access token:

After logging in to ChatGPT's official website, open the F12 developer tools and check the accessToken returned by the https://chat.openai.com/api/auth/session request.

image-20230426010400758

docker run \
    -itd \
    --name pandora2 \
    --restart always \
		-p 7862:7861 \
    -e PANDORA_ACCESS_TOKEN=your_access_token  \
    -e PANDORA_SERVER='0.0.0.0:7861' \
    pengzhile/pandora

After confirming that the firewall is open for the corresponding port (7861), check if it is running correctly by accessing the IP address followed by the port number.

If it is not working, check the error message by running docker logs pandora and ask ChatGPT for help. Usually, there shouldn't be any problems!

Configure reverse proxy#

Now that npm and Pandora are running correctly, the next step is to enable domain name access. First, make sure your domain name is resolved to your server's IP address.

I use dnspod for hosting, and you can see that I have already set it up.

image-20230426011842148

Then configure npm.

image-20230426011642437

The "domain names" field is where you set the domain name. I recommend using a subdomain. If you only have one project, you can use a top-level domain directly.

Do not blindly enter 127.0.0.1 in the "forward hostname/ip" field!

Because npm is bridged to the server through a Docker container's bridge, it bypasses the server's local ports. So you need to enter the gateway of your Docker to ensure that your data is always transmitted within your server. (I'm not sure if I explained this clearly, I did my best. I've learned about the six network modes of Docker, but I've forgotten them all. Also, I'm an arts student.)

Get the Docker gateway#

ip route

image-20230426012340965

Then enter the "forward port" field. I use 7862 because I have set up two instances, one for regular GPT for my friends to use, which occupies port 7861, and another for my esteemed GPT4 subscription users who pay $20 per month, which uses port 7862.

image-20230426012551362

Then select "Get a new certificate" for SSL certificate, or obtain a wildcard certificate in one step. You can research this further.

Configure access restrictions#

This is very important and determines whether you keep it private or expose it to the public.

image-20230426012738264

allow change this to your IP address or the specific IP address for accessing this GPT;
deny all;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Since I'm in a dormitory, I always get a specific range of IP addresses no matter how I connect to the internet. So I set the IP range to only allow access from that range. Of course, you can also restrict access by using npm's access lists, setting passwords, etc. I tried it, but I can only say that I couldn't figure it out. I prefer to rely on the old ways of nginx and write it directly in the configuration.

When I'm in the dormitory, I can access it without any issues.

When I'm outside, I use port forwarding to access my dormitory's internal network environment through a vmess server port on my dormitory's software router. I'm a lazy person, and this method is very dangerous as it exposes the internal network devices if it is brute-forced.

You can also set up a separate proxy server for access or set a password.

After configuring everything, test it by accessing it using mobile data to confirm if the IP restriction is working.

Package the web page using pake#

Environment configuration for Windows/Linux#

  • Very important Check the dependency guide provided by Tauri: Dependency Guide

  • Install all the dependencies mentioned in the guide and then restart.

Install#

npm install -g pake-cli

Package your GPT web page#

pake url

Then it will guide you to name it or customize the icon. The pake documentation is really clear and nice!

Congratulations!#

image-20230426013801378

image-20230426013830412

Two words: elegant!

If you have any questions, feel free to DM me on Twitter. This is my first time writing a tutorial, so there may be some gaps. But this is the result of my practical experience. Thank you for reading.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.