Log the real remote IP address when running behind a proxy
When logging requests, the IP of the remote endpoint is logged, but this is based on the raw network connection. When Pode is running behind a reverse proxy (traefik in my case), the source IP address is my traefik host, but traefik adds the header X-Forwarded-For with the original source IP.
I think the host address for logging is set in src/Private/Logging.ps1 on line 298 with Host = $Request.RemoteEndPoint.Address.IPAddressToString.
Could we set the host using X-Forwarded-For if present, and fall back to the value of RemoteEndpoint.Address? Or is there a way we could configure the server with the header to use for the host address? For example, I also have the X-Real-Ip header.
Here's a request log line for reference:
172.16.2.25 - - [24/Jul/2025:16:00:45 +00:00] "POST /debug HTTP/1.1" 200 3464 "-" "Mozilla/5.0 (Windows NT; Windows NT 10.0; en-US) WindowsPowerShell/5.1.22621.5624"
I thought I'd try grabbing the header myself using Enable-PodeRequestLogging -Raw, but the resulting object does not provide the original request headers.
Hi @joshooaj,
It should be possible to add some -RemoteIPHeader parameter to Enable-PodeRequestLogging. If not supplied it defaults to simply using RemoteEndpoint.Address, otherwise it'll check for the supplied Header before default to RemoteEndpoint.Address
Could possibly make it an array, to support checking for multiple HTTP Headers before defaulting 🤔