Bad Gateway Error 502 when trying to setup a reverse proxy, docker

I’m trying to setup Home Assistant on my Raspberry Pi, running docker with a reverse proxy.

IP of my Raspberry Pi is 192.168.2.10
My docker network, called npm_proxy has a subnet of 192.168.89.0/24
The IP of the container running NGINX Proxy Manager is 192.168.89.254

This is my docker-compose.yaml with home assistant config:

# Home Assistant
  homeassistant:
    container_name: homeassistant
    image: "ghcr.io/home-assistant/home-assistant:stable"
    networks:
    # For Static IP
      npm_proxy:
        ipv4_address: 192.168.89.2 # static IP
    ports:
      - "2000:2000"
    volumes:
      - /home/potterman/docker/appdata/homeassistant/config:/config
      - /home/potterman/docker/appdata/homeassistant/data:/data
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    privileged: true

This is my Nginx Proxy Manager docker-compose:

# Nginx Proxy Manager - Reverse Proxy with LetsEncrypt
  npm:
    <<: *common-keys-core # See EXTENSION FIELDS at the top
    container_name: nginx-proxy-manager
    image: 'jc21/nginx-proxy-manager:latest'
    # For Static IP
    networks:
    # For Static IP
      npm_proxy:
        ipv4_address: 192.168.89.254 # You can specify a static IP
    # For Dynamic IP
    # networks:
    #  - npm_proxy
    ports:
      - '80:80' # Public HTTP Port. Port Forwarding on Router is ON.
      - '443:443' # Public HTTPS Port. Port Forwarding on Router is ON.
      - '81:81' # Admin Web Port. Port Forwarding on Router is OFF.
    volumes:
      - /home/potterman/docker/appdata/npm/config:/config
      - /home/potterman/docker/appdata/npm/letsencrypt:/etc/letsencrypt
      - /home/potterman/docker/appdata/npm/data:/data
    environment:
      DB_SQLITE_FILE: "/config/database.sqlite"
      DISABLE_IPV6: "true"

And the dockers network config:

########################### NETWORKS
networks:
  default:
    driver: bridge
  npm_proxy:
    name: npm_proxy
    driver: bridge
    ipam:
      config:
        - subnet: 192.168.89.0/24

HA config:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

http:
  use_x_forwarded_for: true
  trusted_proxies:
   - 127.0.0.1
   - 192.168.89.254 # This is the IP of the container with my nginx-proxy-manager
   - 192.168.2.0/24 # This is my home network
   - 192.168.89.0/24 # This is my Docker's network subnet

And a config for a domain inside nginx proxy manager:

The domain for the proxy manager works completely fine though, I can’t seem to find anything different in my config when it comes to HA.
I’m not sure what to try next

Well your Home Assistant config doesn’t show that you are listening on port 2000? Are you? Because it should be 8123 in NPM if you haven’t specifically told HA to listen on port 2000

And the same applies to the docker config for Home Assistant too. You are mapping 2000 external to 2000 internal, but Home Assistant isn’t listening on port 2000 unless you tell it to in the config.

Edit additionally, I would recommend allowing Home Assistant access to the host network, otherwise a lot of auto discovery stuff probably isn’t going to work.

1 Like

I added the port in the HA config, its now working as intended.
Can I have HA both be on the npm_proxy network and the host network?

I believe so - you just add another network to the docker config usually. I’m not entirely sure how Home Assistant copes with having multiple interfaces though - can only try it I guess.