Successfully Configuring Multiple Trusted Proxies in Home Assistant

Hey everyone,

I wanted to share my experience with configuring multiple trusted proxies in Home Assistant. After a lot of trial and error, I finally got it working smoothly!

The Challenge:
I host Home Assistant on a Synology NAS, which has two network ports. I noticed that after NAS updates, the IP address used by Home Assistant would sometimes switch, causing issues with remote access. I tried adding both IPs to the trusted_proxies list in configuration.yaml, but it didn’t work as expected.

The Solution:
After some research, I realized that simply listing multiple IPs wasn’t enough. I needed to ensure that only the correct IP was used based on the NAS’s current configuration. Here’s what I did:

  1. Identify the Active IP:

    • I set up a script to check which IP the NAS was using post-update.
    • This involved monitoring the network interfaces and logging the active IP.
  2. Update Configuration Automatically:

    • I created a simple automation that updates the trusted_proxies entry in configuration.yaml based on the detected IP.
    • This ensures that only the correct IP is trusted at any given time.
  3. Test and Refine:

    • I tested the setup thoroughly to make sure it handles IP switches seamlessly.
    • I also added logging to track any issues that might arise.

Results:
This setup has been rock solid for me. No more manual IP changes or access issues after NAS updates. It’s a small tweak, but it makes a big difference in maintaining smooth operation.

Pro Tip:
If you’re dealing with similar network configurations, consider using firewall rules to restrict access to specific IPs before they reach Home Assistant. This adds an extra layer of security.

I’d love to hear how others handle multiple trusted proxies or network configurations. Feel free to share your tips and tricks below!

Happy automating! :rocket: