Skip to content

Unable to set up the backend. With Traefik on Docker Swarm #257

@Cloufish

Description

@Cloufish

I've followed the documentation and tweaked docker-compose.yml to be compatible with Docker Swarm and also Traefik routing
However, I still encounter issues going to https://wsgi-backend and https://server-backend

On wsgi I get page 404, on server-backend I get Bad Gateway (because in the Docker EXPOSE 80 is specified)

If there are any other files/logs I can provide let me know

docker-compose.yml

version: "3.7"

services:
  chatgpt:
    image: wongsaang/chatgpt-ui-client:latest
    container_name: chatgpt
    restart: unless-stopped
    networks:
      - web    # The assignment for Traefik to work
      - chatgpt
    environment:
      - SERVER_DOMAIN=http://chatgpt-backend-web.home
      - PUID=1000
      - PGID=1000
      - DEBUG=True
      - DEFAULT_LOCALE=en
      - TZ=Europe/Warsaw
    depends_on:
      - chatgpt-backend-web
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.chatgpt.rule=Host(`chatgpt.home`)"
        - "traefik.http.services.chatgpt.loadbalancer.server.port=80"
        - "traefik.docker.network=web"
        - "io.portainer.accesscontrol.users=admin"
        - "traefik.http.routers.chatgpt.tls=true"

  chatgpt-backend-wsgi:
    image: wongsaang/chatgpt-ui-wsgi-server:latest
    environment:
      - APP_DOMAIN=http://chatgpt-backend-web.home:9000
      - DEBUG=True
      - 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=password # default superuser password
      - [email protected] # 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 protected]  #Default sender email address
    volumes:
      - /home/swarm/chatgpt/db.sqlite3:/app/db.sqlite3
    networks:
      - web
      - chatgpt
    restart: always
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.chatgpt-backend-wsgi.rule=Host(`chatgpt-backend-wsgi.home`)"
        - "traefik.http.services.chatgpt-backend-wsgi.loadbalancer.server.port=8000"
        - "traefik.docker.network=web"
        - "io.portainer.accesscontrol.users=admin"
        - "traefik.http.routers.chatgpt-backend-wsgi.tls=true"

  chatgpt-backend-web:
    image: wongsaang/chatgpt-ui-web-server:latest
    environment:
      - BACKEND_URL=http://chatgpt-backend-wsgi.home:8000
      - DEBUG=True
    depends_on:
      - chatgpt-backend-wsgi
    networks:
      - web
      - chatgpt
    expose: 
      - 8000 # To overwrite the EXPOSE 80 in Dockerfile. doesn't work though
    restart: always
    deploy:
      labels:
        - "traefik.enable=true"
        - "traefik.http.routers.chatgpt-backend-web.rule=Host(`chatgpt-backend-web.home`)"
        - "traefik.http.services.chatgpt-backend-web.loadbalancer.server.port=8000" # In Dockerfile the port that is EXPOSEd is 80
        - "traefik.docker.network=web"
        - "io.portainer.accesscontrol.users=admin"
        - "traefik.http.routers.chatgpt-backend-web.tls=true"

networks:
  chatgpt:
    driver: bridge 
    attachable: true
    name: chatgpt
  web:
    external: true
    name: web

volumes: 
  chatgpt-volume:
    driver: local 

image
image
image
image

chatgpt-client logs:

Listening http://[::]:80
(node:1) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added to [Server]. Use emitter.setMaxListeners() to increase limit
(Use `node --trace-warnings ...` to show where the warning was created)

chatgpt-wsgi:

Operations to perform:
  Apply all migrations: account, admin, auth, chat, contenttypes, provider, sessions, sites, socialaccount, stats
Running migrations:
  No migrations to apply.
Setting up default settings...
CommandError: Error: That username is already taken.
[2024-01-10 14:46:39 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2024-01-10 14:46:39 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
[2024-01-10 14:46:39 +0000] [1] [INFO] Using worker: sync
[2024-01-10 14:46:39 +0000] [35] [INFO] Booting worker with pid: 35
[2024-01-10 14:46:39 +0000] [36] [INFO] Booting worker with pid: 36
[2024-01-10 14:46:39 +0000] [37] [INFO] Booting worker with pid: 37
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 4031 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/fontawesome-free-6.2.0-web/css/all.min.css
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/fontawesome-free-6.2.0-web/css/all.min.css HTTP/1.1" 404 2942 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/css/login.css
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/css/login.css?_=2.1 HTTP/1.1" 404 2861 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/js/vue.min.js
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/js/vue.min.js?_=2023.03.01 HTTP/1.1" 404 2868 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/elementui/index.js
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/elementui/index.js?_=2023.03.01 HTTP/1.1" 404 2883 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/particles/app.js
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/particles/app.js HTTP/1.1" 404 2864 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/particles/particles.js
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/particles/particles.js HTTP/1.1" 404 2882 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/js/login.js
10.0.1.49 - - [10/Jan/2024:14:50:52 +0000] "GET /static/admin/simpleui-x/js/login.js?_=3.3 HTTP/1.1" 404 2855 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/img/logo.png
10.0.1.49 - - [10/Jan/2024:14:50:53 +0000] "GET /static/admin/simpleui-x/img/logo.png HTTP/1.1" 404 2852 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/elementui/theme-chalk/index.css
10.0.1.49 - - [10/Jan/2024:14:50:53 +0000] "GET /static/admin/simpleui-x/elementui/theme-chalk/index.css HTTP/1.1" 404 2909 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/img/bg.svg
��
10.0.1.49 - - [10/Jan/2024:14:50:53 +0000] "GET /static/admin/simpleui-x/img/bg.svg HTTP/1.1" 404 2846 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
�
Not Found: /
10.0.1.49 - - [10/Jan/2024:14:50:58 +0000] "GET / HTTP/1.1" 404 2726 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
10.0.1.49 - - [10/Jan/2024:15:02:04 +0000] "GET /admin/ HTTP/1.1" 302 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
10.0.1.49 - - [10/Jan/2024:15:02:04 +0000] "GET /admin/login/?next=/admin/ HTTP/1.1" 200 4031 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/elementui/theme-chalk/index.css
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/elementui/theme-chalk/index.css HTTP/1.1" 404 2909 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/css/login.css
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/css/login.css?_=2.1 HTTP/1.1" 404 2861 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/img/logo.png
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/img/logo.png HTTP/1.1" 404 2852 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/js/vue.min.js
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/js/vue.min.js?_=2023.03.01 HTTP/1.1" 404 2868 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/elementui/index.js
Not Found: /static/admin/simpleui-x/particles/app.js
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/elementui/index.js?_=2023.03.01 HTTP/1.1" 404 2883 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/particles/app.js HTTP/1.1" 404 2864 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/particles/particles.js
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/particles/particles.js HTTP/1.1" 404 2882 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/js/login.js
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/js/login.js?_=3.3 HTTP/1.1" 404 2855 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/fontawesome-free-6.2.0-web/css/all.min.css
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/fontawesome-free-6.2.0-web/css/all.min.css HTTP/1.1" 404 2942 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
Not Found: /static/admin/simpleui-x/img/bg.svg
��
10.0.1.49 - - [10/Jan/2024:15:02:05 +0000] "GET /static/admin/simpleui-x/img/bg.svg HTTP/1.1" 404 2846 "https://chatgpt-backend-wsgi.home/admin/login/?next=/admin/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"

chatgpt-backend-server:

/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/01/10 14:42:37 [notice] 1#1: using the "epoll" event method
2024/01/10 14:42:37 [notice] 1#1: nginx/1.22.1
2024/01/10 14:42:37 [notice] 1#1: built by gcc 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4) 
2024/01/10 14:42:37 [notice] 1#1: OS: Linux 6.2.0-26-generic
2024/01/10 14:42:37 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/01/10 14:42:37 [notice] 1#1: start worker processes
2024/01/10 14:42:37 [notice] 1#1: start worker process 35
2024/01/10 14:42:37 [notice] 1#1: start worker process 36
2024/01/10 14:42:37 [notice] 1#1: start worker process 37
2024/01/10 14:42:37 [notice] 1#1: start worker process 38
2024/01/10 14:42:37 [notice] 1#1: start worker process 39
2024/01/10 14:42:37 [notice] 1#1: start worker process 40
2024/01/10 14:42:37 [notice] 1#1: start worker process 41
2024/01/10 14:46:27 [notice] 1#1: signal 3 (SIGQUIT) received, shutting down
2024/01/10 14:46:27 [notice] 35#35: gracefully shutting down
2024/01/10 14:46:27 [notice] 35#35: exiting
2024/01/10 14:46:27 [notice] 35#35: exit
2024/01/10 14:46:27 [notice] 36#36: gracefully shutting down
2024/01/10 14:46:27 [notice] 38#38: gracefully shutting down
2024/01/10 14:46:27 [notice] 37#37: gracefully shutting down
2024/01/10 14:46:27 [notice] 36#36: exiting
2024/01/10 14:46:27 [notice] 39#39: gracefully shutting down
2024/01/10 14:46:27 [notice] 37#37: exiting
2024/01/10 14:46:27 [notice] 38#38: exiting
2024/01/10 14:46:27 [notice] 40#40: gracefully shutting down
2024/01/10 14:46:27 [notice] 39#39: exiting
2024/01/10 14:46:27 [notice] 40#40: exiting
2024/01/10 14:46:27 [notice] 36#36: exit
2024/01/10 14:46:27 [notice] 37#37: exit
2024/01/10 14:46:27 [notice] 40#40: exit
2024/01/10 14:46:27 [notice] 38#38: exit
2024/01/10 14:46:27 [notice] 39#39: exit
2024/01/10 14:46:27 [notice] 41#41: gracefully shutting down
2024/01/10 14:46:27 [notice] 41#41: exiting
2024/01/10 14:46:27 [notice] 41#41: exit
2024/01/10 14:46:27 [notice] 1#1: signal 17 (SIGCHLD) received from 37
2024/01/10 14:46:27 [notice] 1#1: worker process 37 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: worker process 40 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: worker process 35 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: signal 29 (SIGIO) received
2024/01/10 14:46:27 [notice] 1#1: signal 17 (SIGCHLD) received from 35
2024/01/10 14:46:27 [notice] 1#1: signal 17 (SIGCHLD) received from 41
2024/01/10 14:46:27 [notice] 1#1: worker process 38 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: worker process 41 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: signal 29 (SIGIO) received
2024/01/10 14:46:27 [notice] 1#1: signal 17 (SIGCHLD) received from 39
2024/01/10 14:46:27 [notice] 1#1: worker process 39 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: signal 29 (SIGIO) received
2024/01/10 14:46:27 [notice] 1#1: signal 17 (SIGCHLD) received from 36
2024/01/10 14:46:27 [notice] 1#1: worker process 36 exited with code 0
2024/01/10 14:46:27 [notice] 1#1: exit
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: IPv6 listen already enabled
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
20-envsubst-on-templates.sh: Running envsubst on /etc/nginx/templates/default.conf.template to /etc/nginx/conf.d/default.conf
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2024/01/10 14:46:28 [notice] 1#1: using the "epoll" event method
2024/01/10 14:46:28 [notice] 1#1: nginx/1.22.1
2024/01/10 14:46:28 [notice] 1#1: built by gcc 12.2.1 20220924 (Alpine 12.2.1_git20220924-r4) 
2024/01/10 14:46:28 [notice] 1#1: OS: Linux 6.2.0-26-generic
2024/01/10 14:46:28 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024/01/10 14:46:28 [notice] 1#1: start worker processes
2024/01/10 14:46:28 [notice] 1#1: start worker process 27
2024/01/10 14:46:28 [notice] 1#1: start worker process 28
2024/01/10 14:46:28 [notice] 1#1: start worker process 29
2024/01/10 14:46:28 [notice] 1#1: start worker process 30
2024/01/10 14:46:28 [notice] 1#1: start worker process 31
2024/01/10 14:46:28 [notice] 1#1: start worker process 32
2024/01/10 14:46:28 [notice] 1#1: start worker process 33

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions