I’m trying to setup fail2ban on my server. I’m running the HomeAssistant docker image behind nginx which listens for requests from my public website. All failed auth attempts log as coming from ip address ::1
which I’m not sure what that means but I believe it’s because the host_addr
is not being forwarded from nginx. So I followed the docs (Fail2Ban - Home Assistant) and added the following to my nginx server config:
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Now the problem I’m having: I’m trying to add the required line to my configuration.yml be the home-assistant docs.
http:
use_x_forwarded_for: true
But I get a config error in HA:
Invalid config for [http]: some but not all values in the same group of inclusion 'proxy' @ data['http'][<proxy>]. Got None. (See /config/configuration.yaml, line 36).
Reading the docs at HTTP - Home Assistant, it says:
You must also whitelist trusted proxies using the
trusted_proxies
setting for this to work.
Changing my config file to:
http:
use_x_forwarded_for: true
trusted_proxies:
- 127.0.0.1
Allows the config file to checkout but the server returns other errors.
2020-11-09 12:33:08 WARNING (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from untrusted proxy ::1, headers not processed
2020-11-09 12:33:08 ERROR (MainThread) [homeassistant.components.http.forwarded] Too many headers for X-Forwarded-For: ['<my_external_ip>', '<my_external_ip>']
2020-11-09 12:33:09 WARNING (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from untrusted proxy ::1, headers not processed
2020-11-09 12:33:09 ERROR (MainThread) [homeassistant.components.http.forwarded] Too many headers for X-Forwarded-For: ['<my_external_ip>', '<my_external_ip>']
2020-11-09 12:33:10 WARNING (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from untrusted proxy ::1, headers not processed
2020-11-09 12:33:10 ERROR (MainThread) [homeassistant.components.http.forwarded] Too many headers for X-Forwarded-For: ['<my_external_ip>', '<my_external_ip>']
2020-11-09 12:33:20 WARNING (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from untrusted proxy ::1, headers not processed
2020-11-09 12:33:20 ERROR (MainThread) [homeassistant.components.http.forwarded] Too many headers for X-Forwarded-For: ['<my_external_ip>', '<my_external_ip>']
2020-11-09 12:33:20 WARNING (MainThread) [homeassistant.components.http.forwarded] Received X-Forwarded-For header from untrusted proxy ::1, headers not processed
2020-11-09 12:33:20 ERROR (MainThread) [homeassistant.components.http.forwarded] Too many headers for X-Forwarded-For: ['<my_external_ip>', '<my_external_ip>']
How do I set up fail2ban to work with Home Assistant?