Nginx proxy 502 bad gateway

I have been getting 502 bad gateway errors with nginx.My config looks right to me.I am running HASS OS in a hyper-v vm.Here is my config file:

# Loads default set of integrations. Do not remove.

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

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

  use_x_forwarded_for: true

I run nginx in a docker container on a raspberry pi which is on a different machine than my vm.In the nginx error log it says

2024/01/26 00:55:38 [error] 461#461: *7221 homeassistant.local could not be resolved (2: Server failure), client:, server:, request: "GET / HTTP/2.0", host: "", referrer: ""

I know I have IP addresses here, but I do not expose any ports. I can not ping/curl -v from my raspberry pi, but can from other computer.If you need any config or logs please tell me.

That DNS name relies on having you VM in “bridge” mode, i.e. allowing broadcasts to your LAN network (192.168.255?).
Try with the IP address of the VM host (assuming proper port forwarding is in place there to HAOS)

What do you mean,

Do i need to add the ip of the machine hosting the VM to trusted proxies in configuration.yaml.

Random tutorial:

Also, I am running ubuntu on my raspberry pi. I might have been typing the name wrong before, but I can now access homeassistant.local:8123 from my raspberry pi.I changed the VM network to bridge mode but it did not do anything. I use duckdns for my domain and it points to the ip of the proxy

Ah, well, it’s basically the same issue but at the other end: unless your docker container (the nginx one) runs in host networking mode, it doesn’t have access the “mDns” (the “.local” dns space) either.

Bottom line, to avoid headaches, don’t use mDNS on non-simple setups (VM’s, docker, …)

so should I install nginx through home assistant directly as an add on. And I am new to docker and home assistant, so what is host networking mode

I figured it out. You need to install mariadb, (maybe not, I don’t know yet) nginx proxy manager (NOT the ssl proxy). To get Ngnix you need to enable advanced mode in user settings. The default credentials for nginx are: [email protected], and the password is changeme. you then need to set up your info, after that set up a proxy host with your domain name, ip of home assistant os for the hostname/ip, and port 8123 with websockets support. after you set that up visit you domain and if you get 400: bad request, use a file browser of your choice, and check the home assistant log for something like this:

2024-01-28 09:32:19.013 ERROR (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from an untrusted proxy

get the ip and remember it in configuration.yaml put this in:

  use_x_forwarded_for: true
    - home assistant machine ip
    - ip from log

then reboot home assistant and when you visit your domain you should be greeted with the log in screen.