[GH-ISSUE #1202] nginx with internal docker network #12393

Closed
opened 2026-04-19 19:17:57 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @dannongruver on GitHub (Mar 18, 2024).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/1202

I'm attempting to run open-webui in docker on an internal network. Since the network's internal it can't access the host/internet, I'm also attempting to reverse proxy to the host via nginx. I'm successfully able to serve up static pages from open-webui (eg favicon.png) using nginx but not the dynamic pages. Also open-webui works without using this internal network and reverse proxy.

Although this is a docker/nginx question, the reason I'm asking this here is because it appears that open-webui is running on Uvicorn. According to Uvicorn's documentation (https://www.uvicorn.org/deployment/#running-behind-nginx) these settings may need to be set: --forwarded-allow-ips='*' and --proxy-headers.

My questions:

  1. Is there a way to expose those Uvicorn properties?
  2. If this works, can the correct yaml for this scenario be added to docs.

I'm not an expert at any of this so I'm sure I have the wrong configuration somewhere.

Here's my docker-compose yaml:

version: '3.8'
services:
    ollama:
        deploy:
            resources:
                reservations:
                    devices:
                        - driver: nvidia
                          count: all
                          capabilities:
                              - gpu
        volumes:
            - C:\Projects\LocalLLM\ollama:/root/.ollama
        ports:
            - 11434:11434
        container_name: ollama
        image: ollama/ollama
        command: 
        networks:
          isolated:
    open-webui:
        ports:
            - 8080:8080
        extra_hosts:
            - host.docker.internal:host-gateway
        container_name: open-webui
        restart: always
        image: ghcr.io/open-webui/open-webui:main
        depends_on:
            - ollama
        networks:
            - isolated

    nginx:
        container_name: nginx
        ports:
            - 80:80
        image: nginx:latest
        depends_on:
            - open-webui
        networks:
            - isolated    
            - internet
networks:
    isolated:
        driver: bridge
        internal: true
    internet:
        driver: bridge

Here's my nginx config (copied from https://www.uvicorn.org/deployment/#running-behind-nginx):

server {
    listen 80;
    client_max_body_size 4G;

    server_name localhost;

    location / {
      proxy_set_header Host $http_host;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header X-Forwarded-Proto $scheme;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header Connection $connection_upgrade;
      proxy_redirect off;
      proxy_buffering off;
      proxy_pass http://open-webui:8080;
    }

    location /static {
      # path for static files
      root /path/to/app/static;
    }
  }

  map $http_upgrade $connection_upgrade {
    default upgrade;
    '' close;
  }

  upstream uvicorn {
    server unix:/tmp/uvicorn.sock;
  }

here are open-webui container logs

2024-03-18 18:35:11 No WEBUI_SECRET_KEY provided
2024-03-18 18:35:11 Generating WEBUI_SECRET_KEY
2024-03-18 18:35:11 Loading WEBUI_SECRET_KEY from .webui_secret_key
2024-03-18 18:35:19 
2024-03-18 18:35:19 #------------------------------------------------------------#
2024-03-18 18:35:19 #                                                            #
2024-03-18 18:35:19 #           'It would help me if you could add...'            #
2024-03-18 18:35:19 #        https://github.com/BerriAI/litellm/issues/new        #
2024-03-18 18:35:19 #                                                            #
2024-03-18 18:35:19 #------------------------------------------------------------#
2024-03-18 18:35:19 
2024-03-18 18:35:19  Thank you for using LiteLLM! - Krrish & Ishaan
2024-03-18 18:35:19 
2024-03-18 18:35:19 
2024-03-18 18:35:19 
2024-03-18 18:35:19 Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
2024-03-18 18:35:19 
2024-03-18 18:35:19 
2024-03-18 18:35:19 INFO:     192.168.128.1:0 - "GET /favicon.png HTTP/1.0" 200 OK
2024-03-18 18:35:26 INFO:     192.168.128.1:0 - "GET / HTTP/1.0" 304 Not Modified
2024-03-18 18:35:15 INFO:     Started server process [1]
2024-03-18 18:35:15 INFO:     Waiting for application startup.
2024-03-18 18:35:15 INFO:     Application startup complete.
2024-03-18 18:35:15 INFO:     Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)

here are nginx container logs:```

2024-03-18 18:35:12 /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
2024-03-18 18:35:12 /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
2024-03-18 18:35:12 /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
2024-03-18 18:35:12 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf
2024-03-18 18:35:12 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version
2024-03-18 18:35:12 /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
2024-03-18 18:35:12 /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
2024-03-18 18:35:12 /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
2024-03-18 18:35:12 /docker-entrypoint.sh: Configuration complete; ready for start up
2024-03-18 18:35:19 192.168.128.1 - - [18/Mar/2024:23:35:19 +0000] "GET /favicon.png HTTP/1.1" 200 6161 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "-"
2024-03-18 18:35:26 192.168.128.1 - - [18/Mar/2024:23:35:26 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "-"
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: using the "epoll" event method
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: nginx/1.25.4
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14) 
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: OS: Linux 5.15.146.1-microsoft-standard-WSL2
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker processes
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 29
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 30
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 31
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 32
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 33
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 34
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 35
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 36
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 37
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 38
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 39
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 40
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 41
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 42
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 43
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 44
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 45
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 46
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 47
2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 48
Originally created by @dannongruver on GitHub (Mar 18, 2024). Original GitHub issue: https://github.com/open-webui/open-webui/issues/1202 I'm attempting to run open-webui in docker on an **internal** network. Since the network's internal it can't access the host/internet, I'm also attempting to reverse proxy to the host via nginx. I'm successfully able to serve up static pages from open-webui (eg favicon.png) using nginx but not the dynamic pages. Also open-webui works without using this internal network and reverse proxy. Although this is a docker/nginx question, the reason I'm asking this here is because it appears that open-webui is running on Uvicorn. According to Uvicorn's documentation (https://www.uvicorn.org/deployment/#running-behind-nginx) these settings may need to be set: `--forwarded-allow-ips='*'` and `--proxy-headers`. My questions: 1) Is there a way to expose those Uvicorn properties? 2) If this works, can the correct yaml for this scenario be added to docs. _I'm not an expert at any of this so I'm sure I have the wrong configuration somewhere._ Here's my docker-compose yaml: ``` version: '3.8' services: ollama: deploy: resources: reservations: devices: - driver: nvidia count: all capabilities: - gpu volumes: - C:\Projects\LocalLLM\ollama:/root/.ollama ports: - 11434:11434 container_name: ollama image: ollama/ollama command: networks: isolated: open-webui: ports: - 8080:8080 extra_hosts: - host.docker.internal:host-gateway container_name: open-webui restart: always image: ghcr.io/open-webui/open-webui:main depends_on: - ollama networks: - isolated nginx: container_name: nginx ports: - 80:80 image: nginx:latest depends_on: - open-webui networks: - isolated - internet networks: isolated: driver: bridge internal: true internet: driver: bridge ``` Here's my nginx config (copied from https://www.uvicorn.org/deployment/#running-behind-nginx): ``` server { listen 80; client_max_body_size 4G; server_name localhost; location / { proxy_set_header Host $http_host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_redirect off; proxy_buffering off; proxy_pass http://open-webui:8080; } location /static { # path for static files root /path/to/app/static; } } map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream uvicorn { server unix:/tmp/uvicorn.sock; } ``` here are open-webui container logs ``` 2024-03-18 18:35:11 No WEBUI_SECRET_KEY provided 2024-03-18 18:35:11 Generating WEBUI_SECRET_KEY 2024-03-18 18:35:11 Loading WEBUI_SECRET_KEY from .webui_secret_key 2024-03-18 18:35:19 2024-03-18 18:35:19 #------------------------------------------------------------# 2024-03-18 18:35:19 # # 2024-03-18 18:35:19 # 'It would help me if you could add...' # 2024-03-18 18:35:19 # https://github.com/BerriAI/litellm/issues/new # 2024-03-18 18:35:19 # # 2024-03-18 18:35:19 #------------------------------------------------------------# 2024-03-18 18:35:19 2024-03-18 18:35:19 Thank you for using LiteLLM! - Krrish & Ishaan 2024-03-18 18:35:19 2024-03-18 18:35:19 2024-03-18 18:35:19 2024-03-18 18:35:19 Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new 2024-03-18 18:35:19 2024-03-18 18:35:19 2024-03-18 18:35:19 INFO: 192.168.128.1:0 - "GET /favicon.png HTTP/1.0" 200 OK 2024-03-18 18:35:26 INFO: 192.168.128.1:0 - "GET / HTTP/1.0" 304 Not Modified 2024-03-18 18:35:15 INFO: Started server process [1] 2024-03-18 18:35:15 INFO: Waiting for application startup. 2024-03-18 18:35:15 INFO: Application startup complete. 2024-03-18 18:35:15 INFO: Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit) ``` here are nginx container logs:``` ``` 2024-03-18 18:35:12 /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration 2024-03-18 18:35:12 /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ 2024-03-18 18:35:12 /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 2024-03-18 18:35:12 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf 2024-03-18 18:35:12 10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf differs from the packaged version 2024-03-18 18:35:12 /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh 2024-03-18 18:35:12 /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh 2024-03-18 18:35:12 /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh 2024-03-18 18:35:12 /docker-entrypoint.sh: Configuration complete; ready for start up 2024-03-18 18:35:19 192.168.128.1 - - [18/Mar/2024:23:35:19 +0000] "GET /favicon.png HTTP/1.1" 200 6161 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "-" 2024-03-18 18:35:26 192.168.128.1 - - [18/Mar/2024:23:35:26 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0" "-" 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: using the "epoll" event method 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: nginx/1.25.4 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14) 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: OS: Linux 5.15.146.1-microsoft-standard-WSL2 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker processes 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 29 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 30 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 31 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 32 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 33 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 34 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 35 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 36 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 37 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 38 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 39 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 40 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 41 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 42 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 43 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 44 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 45 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 46 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 47 2024-03-18 18:35:12 2024/03/18 23:35:12 [notice] 1#1: start worker process 48 ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#12393