Docker, Nginx and Proxy pass

  docker, nginx, proxypass

i spend a few days to work on my configuration, but i couldnt get it run. Maybe someone here can help me.

I have a raspi 3 with Raspbian OS Buster. On it i installed docker / docker-compose and two containers. My docker-compose.yml:

---
version "2.1"
services:
nginx:
  image: ghcr..io/linuxserver/nginx
  container_name: nginx
  environment:
    - PUID=1000
    - PGID=1000
    - TZ=Europe/Berlin
  volumes:
    - /home/pi/docker/nginx/config:/config
  ports:
    - 80:80
    - 443:443
  # network_mode: host
  networks:
    - docker_nginx-network
  restart: unless-stopped

homessistant:
  image: ghcr.io/linuxserver/homeassistant
  container_name: homeassistant
  environment:
    - PUID=1000
    - PGID=1000
    - TZ=Europe/Berlin
  volumes:
    - /home/pi/docker/homeassistant/config:/config
  networks:
    - docker_nginx-network
  restart: unless-stopped

networks:
  docker_nginx-network
    external: true

The containers are working as expected. Nginx is listening at port 80 and if i call my raspi with his IP "192.168.178.111" he is showing me the Nginx Welcome Site. If i uncomment the line network_mode and comment the network lines in the file above, i can reach his webinterface at "192.168.178.111:8123". So the homeassistant container seems to work.

But now i dont want to reach homeassistant (and some further containers) with ip:port. I want to call this container with "192.168.178.111/homeassistant".

For this i configured Nginx. The nginx.conf is the standard-one. There are noch site-specific entrys in it. For the site config i edit the "default"-file:

server {
  listen 80 default_server;
  listen 443 ssl;

  root /config/www;
  index index.html index.htm index.php;

  server_name _;
  location /homeassistant {
    proxy_pass     http://172.19.0.3:8123;
    proxy_redirect    off;
  }
}

The homeassistant is in the network above and docker inspect shows me the internal IP 172.19.0.3.

The logs from nginx didnt show errors. The config seems to work because i can reach the welcomesite at raspis ip. If is try IP/homeassistant i get a 404 not found error. In the Nginx error-log i can see that a kind of redirect happens:

open() "config/www/onboarding.html" failed, no such file or directory, client: 192.168.178.21 (think this is my mobile), server: _, request: "GET /onboarding.html, host: "192.168.178.111"

So i’m sure that something in my config isnt correct. It seems that he first connect to homeassistant an his frontend want to load "onbording.html" but for some reasons he didnt stay at the containers IP. Instead of he falls back to the raspis IP…

Any suggestions?
Thanks a lot.

Source: Docker Questions

LEAVE A COMMENT