Skip to main content

Quick Start


Introduction

This tutorial guides you through the quick deployment of a ChatGPT Web Share site and service. You will need:

  • A valid ChatGPT Plus account (enable all beta features in settings)
  • An x64 Linux server
    • System: Ubuntu 20.04 LTS or above, or Debian 10 or above recommended
    • Configuration: At least 2 cores and 2GB of RAM recommended; minimum requirement is 1 core and 1GB
    • A CPU supporting the AVX instruction set is recommended

Installation

1. Preparation

Before starting, please ensure your server can access ChatGPT; otherwise, you may need to use a proxy or Warp. We recommend using a server with good IP quality that can access ChatGPT.

Log into your ChatGPT Plus account and enable all beta features in settings.

If Docker is not yet installed on your machine, please refer to the Docker Official Documentationopen in new window for installation instructions.

2. Create Application Directory and Configuration File

For easy management, data and Docker compose configurations should be stored in a separate folder (cws). Let's create a cws folder in the home directory ~ (modify the path accordingly if you're not in the home directory):

cd ~
mkdir cws && cd cws
mkdir -p data/config

First, we'll write the passwords into environment variables. Modify these according to your setup:

export MONGODB_PASSWORD=password  # MongoDB Password
export INITIAL_ADMIN_PASSWORD=password  # Initial Admin Password

Next, run a Docker container to create the configuration files:

docker run -it --rm \
  -v $PWD/data/config:/tmp/config \
 ghcr.io/chatpire/chatgpt-web-share:latest \
  python /app/backend/manage.py create_config -O /tmp/config --generate-secrets --mongodb-url "mongodb://cws:${MONGODB_PASSWORD}@mongo:27017" --initial-admin-password "${INITIAL_ADMIN_PASSWORD}" --chatgpt-base-url http://ninja:7999/backend-api/

After successful configuration file creation, you will see two files in ~/cws/data/config: config.yaml and credentials.yaml. The above command modifies the configuration files, automatically generates secrets (-G), configures MongoDB (--mongodb-url), creates an initial admin account (--initial-admin-password), and sets the ChatGPT proxy address (--chatgpt-base-url).

Manually Edit Config Files

Alternatively, you can create a simple configuration file and then manually edit the configuration files in data/config:

docker run -it --rm \
  -v $PWD/data/config:/tmp/config \
 ghcr.io/chatpire/chatgpt-web-share:latest \
  python /app/backend/manage.py create_config -O /tmp/config

You can also get config file templates from hereopen in new window.

3. Edit Docker Compose Configuration File

Run the following command to create a .env file:

echo "TZ=Asia/Shanghai" > .env
echo "MONGO_INITDB_DATABASE=cws" >> .env
echo "MONGO_INITDB_ROOT_USERNAME=cws" >> .env
echo "MONGO_INITDB_ROOT_PASSWORD=$MONGODB_PASSWORD" >> .env

Next, create the following Docker compose configuration file docker-compose.yml in the cws directory. It includes CWS itself, Mongo DB, and Ninja. Ninjaopen in new window is a ChatGPT proxy used to bypass Cloudflare verification and Arkose verification during conversations.

version: "3"

services:
  chatgpt-web-share:
    image: ghcr.io/chatpire/chatgpt-web-share:latest
    container_name: cws
    restart: unless-stopped
    ports:
      - 5000:80
    volumes:
      - ./data:/app/backend/data
    environment:
      - TZ=${TZ}
      - CWS_CONFIG_DIR=/app/backend/data/config
    depends_on:
      - mongo

  mongo:
    container_name: mongo
    image: mongo:6.0
    restart: always
    # ports:
    #   - 27017:27017
    volumes:
      - ./mongo_data:/data/db
    environment:
      MONGO_INITDB_DATABASE: ${MONGO_INITDB_DATABASE}
      MONGO_INITDB_ROOT_USERNAME: ${MONGO_INITDB_ROOT_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_INITDB_ROOT_PASSWORD}
  
  ninja:
    image: ghcr.io/gngpp/ninja:latest
    container_name: ninja
    restart: unless-stopped
    command: run --disable-webui
    ports:
      - "7999:7999"
    environment:
      - TZ=Asia/Shanghai
    volumes:
          - "./har/gpt3:/root/.gpt3"
          - "./har/gpt4:/root/.gpt4"

Once everything is ready, run docker-compose up -d to start CWS. You can view logs using docker logs cws -f.

If you're using MongoDB on a NAS and your CPU doesn't support the AVX instruction set, you can use the groundhog2k/mongo:6.0.9 image instead of mongo:6.0.

If all goes well, you can access CWS at http://<your server IP>:5000. Log in with admin and the password you set earlier. After logging in, you can further modify the configuration in the settings page.

3. Configure ChatGPT Proxy

Refer to the Ninja Documentationopen in new window for Ninja configuration.

Configure Ninja

In short, you need to:

  1. Set the ChatGPT proxy address in CWS's configuration to http://ninja:7999/backend-api/ (this should have been done in the previous step).
  2. Place HAR files in cws/har/gpt3 (if GPT 3.5 model encounters captcha) and cws/har/gpt4. You can upload files directly to the respective directories or use the web upload provided by Ninja (visit http://<your server IP>:7999/har/upload).
  3. Visit https://chat.openai.com/api/auth/session and copy the content of the access token item, then enter it in the credentials section of the CWS backend settings.

After completing this step, you can go to the conversation management page in CWS and click the sync conversation button at the top. If everything is set up correctly, you should see old conversations from your ChatGPT Plus account appear in the conversation list.

Next, go to the conversation page, try starting a new GPT-4 conversation, and send a message. If everything works as expected, you should receive a reply from ChatGPT; otherwise, you may need to check your configuration.

4. Next Steps

At this point, CWS is fully deployed. To continue using it, you might want to:

  • Set up a reverse proxy on the server, configure a domain name, and enable HTTPS encryption.
  • Close the external 7999 port for Ninja, such as by commenting it out in the docker compose configuration or using a firewall to restrict access.

Enjoy!