Skip to content

How to solve Home Assistant '400 Bad Request' error with Synology Reverse Proxy

December 25th, 2022 Home Assistant Home Assistant logo and text with all sorts of devices on the background

Some assumptions

  1. You have Home Assistant running nicely on your internal network.

  2. You have a Synology Diskstation running.

  3. You have a (sub)domain pointing to your home network IP / Synology.

  4. You have already created a Reverse Proxy rule for Home Assistant.

Edit Reverse Proxy rule for Home Assistant

Since you already made a Reverse Proxy rule for your Home Assistant server, it is reachable from outside your internal network, but you get that error message. Here’s how to solve it.

Step 1

Open Synology DSM and navigate to Control Panel -> Login Portal -> Advanced. There click on the Reverse Proxy button. You should see your Reverse Proxy rule for Home Assistant, select it and click Edit.

Step 2

In the modal window click on Custom Header. Now click the Create button and select WebSocket.

Adding WebSocket headers to the Reverse Proxy rule.
Adding WebSocket headers to the Reverse Proxy rule

Now you should have these two headers added to the configuration:

Upgrade: $http_upgrade
Connection: $connection_upgrade
Adding WebSocket headers to the Reverse Proxy rule.
Adding WebSocket headers to the Reverse Proxy rule

Step 3

Since we now have the Reverse Proxy configuration set up, we need to tell Home Assistant that a trusted proxy is used. Read more on this in the Home Assistant documentation.

Add the following to your configuration.yaml file:

use_x_forwarded_for: true
- # IP of Synology

Now restart Home Assistant, and all should be working!

About Marcel Bootsman

Marcel discovered the web in 1995. Since then he has paid attention to and worked with lots of technologies and founded his own WordPress oriented business in 2009.

Currently Marcel is Business Development Manager Dutch & DACH Markets at Kinsta where he helps Kinsta's client base grow with Managed WordPress, Application, Database and Static site hosting.

You can contact Marcel on a diverse range of online platforms. Please see the Connect section on the homepage for the details.