[GH-ISSUE #1204] [QUESTION] when behind a reverse proxy, search "my ip" get container's internal ip instead of client's remote ip #722

Closed
opened 2026-02-25 20:36:22 +03:00 by kerem · 1 comment
Owner

Originally created by @paxprot on GitHub (Dec 12, 2024).
Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/1204

Hi, I'm using caddy and cloudflare to reverse proxy whoogle, my caddyfile is here:

search.example.com {
  reverse_proxy http://whoogle-search:5000 { # whoogle-search is the container name
    header_up X-Real-IP {remote}
  }
}

When I search "my ip", I get the result of the internal container ip 172.20.0.3 instead of client's remote ip. I checked the logs in caddy, remote ip (both cloudflare and the real client's ip) should have been sent to whoogle

{"level":"debug","ts":1733982155.3036063,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"whoogle-search:5000","duration":0.2426664,"request":{"remote_ip":"172.
71.210.247","remote_port":"11862","client_ip":"172.71.210.247","proto":"HTTP/2.0","method":"GET","host":"search.example.com","uri":"/element?url=gAAAAABnWnfKtJH6gl4CYzc1QmN66eAfwFRvgQiEyHE5
DrXsJZbOztDnlgvq-RyR2lTrhEKvK6_i9e7SS6i_2RD_GQRYW79HmTa_8D8O5vX1LAGArzz2I-M=&type=image/x-icon","headers":{"X-Forwarded-Host":["search.example.com"],"Cf-Ray":["8f0b6454dbd284d2-HKG"],"Cf-Vi
sitor":["{\"scheme\":\"https\"}"],"Accept-Encoding":["gzip, br"],"Cf-Connecting-Ip":["REDACTED"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Ch-Ua":["\"Micros
oft Edge\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\""],"Cookie":["REDACTED"],"Cdn-Loop":["cloudflare; loops=1"],"X-Real-Ip":["172.71.210.247:11862"],"User-Agent":["Mozilla
/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"],"X-Forwarded-Proto":["https"],"Sec-Fetch-Site":["same-origin"],"Acce
pt-Language":["en-US,en;q=0.9"],"X-Forwarded-For":["172.71.210.247"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Cf-Ipcountry":["CN"],"Sec-Fetch-Mode":["n
o-cors"],"Sec-Fetch-Dest":["image"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"search.example.com"}},"headers":{"Content-Type":["image/png"],"Set-
Cookie":["REDACTED"],"Vary":["Cookie"],"X-Frame-Options":["DENY"],"Cache-Control":["max-age=86400"],"Content-Length":["4286"],"Date":["Thu, 12 Dec 2024 05:42:35 GMT"],"Server":["waitress"],
"X-Content-Type-Options":["nosniff"]},"status":200}

How can I get "my ip" return my client's real ip?

Originally created by @paxprot on GitHub (Dec 12, 2024). Original GitHub issue: https://github.com/benbusby/whoogle-search/issues/1204 Hi, I'm using caddy and cloudflare to reverse proxy whoogle, my caddyfile is here: ``` search.example.com { reverse_proxy http://whoogle-search:5000 { # whoogle-search is the container name header_up X-Real-IP {remote} } } ``` When I search "my ip", I get the result of the internal container ip 172.20.0.3 instead of client's remote ip. I checked the logs in caddy, remote ip (both cloudflare and the real client's ip) should have been sent to whoogle ``` {"level":"debug","ts":1733982155.3036063,"logger":"http.handlers.reverse_proxy","msg":"upstream roundtrip","upstream":"whoogle-search:5000","duration":0.2426664,"request":{"remote_ip":"172. 71.210.247","remote_port":"11862","client_ip":"172.71.210.247","proto":"HTTP/2.0","method":"GET","host":"search.example.com","uri":"/element?url=gAAAAABnWnfKtJH6gl4CYzc1QmN66eAfwFRvgQiEyHE5 DrXsJZbOztDnlgvq-RyR2lTrhEKvK6_i9e7SS6i_2RD_GQRYW79HmTa_8D8O5vX1LAGArzz2I-M=&type=image/x-icon","headers":{"X-Forwarded-Host":["search.example.com"],"Cf-Ray":["8f0b6454dbd284d2-HKG"],"Cf-Vi sitor":["{\"scheme\":\"https\"}"],"Accept-Encoding":["gzip, br"],"Cf-Connecting-Ip":["REDACTED"],"Sec-Ch-Ua-Mobile":["?0"],"Sec-Ch-Ua-Platform":["\"Windows\""],"Sec-Ch-Ua":["\"Micros oft Edge\";v=\"131\", \"Chromium\";v=\"131\", \"Not_A Brand\";v=\"24\""],"Cookie":["REDACTED"],"Cdn-Loop":["cloudflare; loops=1"],"X-Real-Ip":["172.71.210.247:11862"],"User-Agent":["Mozilla /5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/131.0.0.0"],"X-Forwarded-Proto":["https"],"Sec-Fetch-Site":["same-origin"],"Acce pt-Language":["en-US,en;q=0.9"],"X-Forwarded-For":["172.71.210.247"],"Accept":["image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"],"Cf-Ipcountry":["CN"],"Sec-Fetch-Mode":["n o-cors"],"Sec-Fetch-Dest":["image"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"h2","server_name":"search.example.com"}},"headers":{"Content-Type":["image/png"],"Set- Cookie":["REDACTED"],"Vary":["Cookie"],"X-Frame-Options":["DENY"],"Cache-Control":["max-age=86400"],"Content-Length":["4286"],"Date":["Thu, 12 Dec 2024 05:42:35 GMT"],"Server":["waitress"], "X-Content-Type-Options":["nosniff"]},"status":200} ``` How can I get "my ip" return my client's real ip?
kerem 2026-02-25 20:36:22 +03:00
  • closed this issue
  • added the
    question
    label
Author
Owner

@paxprot commented on GitHub (Dec 19, 2024):

I have switched to another project, and I encountered the same issue, the solution is to add the ip returned by cf-connecting-ip in request header to whoogle, something like X-Real-IP or X-Forwarded-For, I haven't tested it on whoogle, but I think they should be the same. The config is here, I'll close the issue as resolved.

search.example.com {
  reverse_proxy http://whoogle-search:5000 {
    header_up X-Real-IP {header.Cf-Connecting-Ip}
  }
}
<!-- gh-comment-id:2552996461 --> @paxprot commented on GitHub (Dec 19, 2024): I have switched to another project, and I encountered the same issue, the solution is to add the ip returned by cf-connecting-ip in request header to whoogle, something like X-Real-IP or X-Forwarded-For, I haven't tested it on whoogle, but I think they should be the same. The config is here, I'll close the issue as resolved. ``` search.example.com { reverse_proxy http://whoogle-search:5000 { header_up X-Real-IP {header.Cf-Connecting-Ip} } } ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/whoogle-search#722
No description provided.