But I’m noticing a strange behaviour. If i add this configuraion, all failed logins look like this in the logfile:
2018-11-19 14:42:18 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from ::ffff:5148:21f1
I would expect to see the IPv4 address here like i do when sniffing the traffic with ngrep (please not that I have anonymized the IP):
T 127.0.0.1:52916 -> 127.0.0.1:8123 [AP]
POST /auth/login_flow/9e6e21bddd86441eafa0e37d7d7bec55 HTTP/1.1..Host: urltoha.li..Connection: upgrade..X-Real-IP: ::ffff:123.236.123.236..X-Forwarded-For: ::ffff:123.236.123.236..Content
-Length: 70..Origin: http://urltoha.li..User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36..Content-Type:
text/plain;charset=UTF-8..Accept: */*..Referer: http://urltoha.li/frontend_latest/authorize.html?response_type=code&client_id=http://urltoha.li/&redirect_uri=http://urltoha.li/?auth_callb
ack%3D1&state=eyJoYXNzVXJsIdggR0cDovL2hvbWllLmxpIiwiY2xpZW50SWQiOdfgHRwOi8vaG9taWUubGkvIn0%3D..Accept-Encoding: gzip, deflate..Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.
7....{"username":"sfsfsf","password":"sfsf","client_id":"http://urltoha.li/"}
This is what my nginx reverse proxy configuration and configuration.yaml look like:
It actually (almost) is. Have a look at this. The only thing odd about your example is, that the last two parts are hex. ::ffff:81.72.33.241 would be a valid IPv6 address. Haven’t seen it with hex anywhere yet.
I’m having a similar issue. I’m running Nginx and my ip bans were showing 172. bans for everything. I added the trusted proxies and use_x_forwarded: True and am now getting the IPv6ish addresses (::ffff:aed8:172b). So how do I get the real IP? The issue is that if there is a real attack and ban, the 172 address locks up everything and I have to go in and clear it before I can access from anywhere. This is fine if I’m at home but not if I’m away.
Which gives us the IP 174.216.23.43. The command whois 174.216.23.43 then tells us, that this IP belongs to Cellco Partnership DBA Verizon Wireless (CLLC).
Great, Thanks! I have an automation that sends me a notification of a failed login attempt, is there a way to have it send the real IP in stead of the Hex parts? OR should I modify the config to show it differently? Sorry for the ignorance, I’m new to all this.
I had been having this problem also, running Hassbian on RPi, nginx on Windows 10 in WSL. After a bit of digging, I believe that the two nginx.conf lines listen [::]:80 default_server ipv6only=off; and listen [::]:443 default_server ipv6only=off; at https://www.home-assistant.io/docs/ecosystem/nginx/ are responsible for this.
I found the solution (that works for me, at any rate), and the explanation, at
In a nutshell, the ipv6only=off parameter produces this effect, and to avoid it the server needs to have two directives for each port, i.e.
ipv6only=on is the default, so omitting it entirely works. The discussion above also says that listen 80 should be sufficient to channel both IPv4 and IPv6, but I don’t know how to test this, and the above works.
opens a socket which supports ipv6 AND ipv4. But to do so, the operating system has to translate a IPv4 address to a ipv6 address internally which leads to the described “problem” above. The address above is the valid ipv6 representation of an ipv4 address.
If you want to avoid this, just open a ipv4 only socket if you don’t mind in using ipv6: