Reverse proxy, downstream Real-IP Topic is solved
Moderators: leecollings, remb0
-
- Posts: 6
- Joined: Saturday 22 May 2021 7:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: CH
- Contact:
Reverse proxy, downstream Real-IP
hi all,
TLDR: request to implement logging of X-Real-IP
I am running Domoticz behind a NGINX reverse proxy with public IP access to connect from the Internet. Unfortunately, I don't see the X-Real-IP (or X-Forwarded-for header) from the downstream request (public IP) being passed to the upstream server (ie: Domoticz). In my Domoticz logs, I always see the IP address of my NGINX server (a private IP).
I realize that in the Domoticz settings you can set your reverse proxy IP address to require authentication, but this is not the problem here. I would really like to see in my logs from which downstream (Internet) IP address users are connecting from. Apart from an information point of view, this would also allow to setup fail2ban to mitigate brute force attacks.
So would it be possible to log the X-Real-IP header (if present) instead of the IP address? Should I request this on the GitHub page?
Thanks for your help!
TLDR: request to implement logging of X-Real-IP
I am running Domoticz behind a NGINX reverse proxy with public IP access to connect from the Internet. Unfortunately, I don't see the X-Real-IP (or X-Forwarded-for header) from the downstream request (public IP) being passed to the upstream server (ie: Domoticz). In my Domoticz logs, I always see the IP address of my NGINX server (a private IP).
I realize that in the Domoticz settings you can set your reverse proxy IP address to require authentication, but this is not the problem here. I would really like to see in my logs from which downstream (Internet) IP address users are connecting from. Apart from an information point of view, this would also allow to setup fail2ban to mitigate brute force attacks.
So would it be possible to log the X-Real-IP header (if present) instead of the IP address? Should I request this on the GitHub page?
Thanks for your help!
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reverse proxy, downstream Real-IP
No but I moved this to the suggestions sub forum. If one of the developers is interested and want to spent time on it, she/he can create a Pull Request and after reviewing it could be integrated in a future version.DomoticzCH wrote: ↑Wednesday 26 May 2021 11:18 So would it be possible to log the X-Real-IP header (if present) instead of the IP address? Should I request this on the GitHub page?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 6
- Joined: Saturday 22 May 2021 7:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: CH
- Contact:
Re: Reverse proxy, downstream Real-IP
Thank you very much!
I think it's a fairly easy modification to the code (just check if X-Real-IP header is present and log that instead of "IP address"), and it would help everyone using a reverse proxy.
I think it's a fairly easy modification to the code (just check if X-Real-IP header is present and log that instead of "IP address"), and it would help everyone using a reverse proxy.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reverse proxy, downstream Real-IP
Please feel free to create a PR for it.DomoticzCH wrote: ↑Wednesday 26 May 2021 16:16 I think it's a fairly easy modification to the code (just check if X-Real-IP header is present and log that instead of "IP address")
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 6
- Joined: Saturday 22 May 2021 7:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: CH
- Contact:
Re: Reverse proxy, downstream Real-IP
Duh, I must have overlooked something... When I put my proxy's IP address in the corresponding field, I now get the real IP addresses in the log! So everything is already perfect 

- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: Reverse proxy, downstream Real-IP
Can you please review this wiki page and advise if something needs more clarification?DomoticzCH wrote: ↑Thursday 27 May 2021 8:35 Duh, I must have overlooked something... When I put my proxy's IP address in the corresponding field, I now get the real IP addresses in the log! So everything is already perfect![]()
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 6
- Joined: Saturday 22 May 2021 7:47
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: CH
- Contact:
Re: Reverse proxy, downstream Real-IP
No, that page is perfect, and if I would have read it until the end, I would have made less of a fool of myself
Especially the end which starts with "Please Note" !

Especially the end which starts with "Please Note" !
-
- Posts: 361
- Joined: Monday 25 December 2017 23:06
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2022.1
- Location: Paris
- Contact:
Re: Reverse proxy, downstream Real-IP
Hi,
I did it like this with Synology I think there is a typo in the wiki
X-Forwarded_Proto => X-Forwarded-Proto
I did it like this with Synology I think there is a typo in the wiki
X-Forwarded_Proto => X-Forwarded-Proto
- waltervl
- Posts: 5851
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Reverse proxy, downstream Real-IP
Fixed, thanks for reporting.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest