WongSaang / chatgpt-ui

A ChatGPT web client that supports multiple users, multiple languages, and multiple database connections for persistent data storage. Provides Docker images and quick deployment scripts.
https://wongsaang.github.io/chatgpt-ui/
MIT License
1.49k stars 325 forks source link

CSRF - 403 #219

Closed sergiorgiraldo closed 1 year ago

sergiorgiraldo commented 1 year ago

I've read all the issues and I couldnt find a way to solve this. I am hosting in Azure so I must put the IP address in the composer file. This is what I have:

  (...)
  backend-wsgi-server:
    platform: linux/x86_64
    image: wongsaang/chatgpt-ui-wsgi-server:latest
    environment:
      - DEBUG=True # Whether to enable debug mode, default False
      - APP_DOMAIN=10.20.30.40:9000
      - DB_URL=${DB_URL:-sqlite:///db.sqlite3} # If this parameter is not set, the built-in Sqlite will be used by default. It should be noted that if you do not connect to an external database, the data will be lost after the container is destroyed.
 (...)

10.20.30.40 is the IP, I can see the chat there and I am able to login successfully. What is wrong here?

enzo-arata commented 1 year ago

@sergiorgiraldo How were you able to get it working with Azure?

sergiorgiraldo commented 1 year ago

Yep, Enzo,

The only way i managed to work was to use a reverse-proxy in apache for a domain I have BUT the admin it only works if I access thru the IP. So, the chat I can use thru my domain but the admin i cant. I am not satisfied but it works, so ¯_(ツ)_/¯

hereby my files on how I setup it, hope it works for you:

~/docker-compose.yaml

version: '3'
services:
  client:
    platform: linux/x86_64
    image: wongsaang/chatgpt-ui-client:latest
    environment:
      - SERVER_DOMAIN=http://backend-web-server
      - DEFAULT_LOCALE=en
#      - NUXT_PUBLIC_APP_NAME='ChatGPT UI' # The name of the application
#      - NUXT_PUBLIC_TYPEWRITER=true # Whether to enable the typewriter effect, default false
#      - NUXT_PUBLIC_TYPEWRITER_DELAY=50 # The delay time of the typewriter effect, default 50ms
    depends_on:
      - backend-web-server
    ports:
      - '${CLIENT_PORT:-80}:80'
    networks:
      - chatgpt_ui_network
    restart: always
  backend-wsgi-server:
    platform: linux/x86_64
    image: wongsaang/chatgpt-ui-wsgi-server:latest
    environment:
      - APP_DOMAIN=20.30.40.50:9000 #ip from vm
      - SERVER_WORKERS=3 # The number of worker processes for handling requests.
      #      - DB_URL=postgres://postgres:postgrespw@localhost:49153/chatgpt # If this parameter is not set, the built-in Sqlite will be used by default. It should be noted that if you do not connect to an external database, the data will be lost after the container is destroyed.
      - DJANGO_SUPERUSER_USERNAME=admin # default superuser name
      - DJANGO_SUPERUSER_PASSWORD=blah # default superuser password
      - DJANGO_SUPERUSER_EMAIL=admin@example.com # default superuser email
      - ACCOUNT_EMAIL_VERIFICATION=${ACCOUNT_EMAIL_VERIFICATION:-none} # Determines the e-mail verification method during signup – choose one of "none", "optional", or "mandatory". Default is "optional". If you don't need to verify the email, you can set it to "none".
      # If you want to use the email verification function, you need to configure the following parameters
#      - EMAIL_HOST=SMTP server address
#      - EMAIL_PORT=SMTP server port
#      - EMAIL_HOST_USER=
#      - EMAIL_HOST_PASSWORD=
#      - EMAIL_USE_TLS=True
#      - EMAIL_FROM=no-reply@example.com  #Default sender email address
    ports:
      - '${WSGI_PORT:-8000}:8000'
    networks:
      - chatgpt_ui_network
    restart: always
  backend-web-server:
    platform: linux/x86_64
    image: wongsaang/chatgpt-ui-web-server:latest
    environment:
      - BACKEND_URL=http://backend-wsgi-server:8000
    ports:
      - '${SERVER_PORT:-9000}:80'
    depends_on:
      - backend-wsgi-server
    networks:
      - chatgpt_ui_network
    restart: always

/etc/apache2/sites-enabled/your-site.conf /etc/apache2/sites-available/your-site.conf

<VirtualHost *:80>
    ServerName your-site.com

    ProxyPreserveHost On
    ProxyPass / http://20.107.188.113/
    ProxyPassReverse / http://20.107.188.113/
</VirtualHost>