Open berkansivri opened 6 months ago
It wold be better if we have an option to pass client_ip
to coraza.
Hi, the related code is https://github.com/corazawaf/coraza-caddy/blob/main/http.go#L24-L33, we are currently using http.Request.RemoteAddr
to fill the client address.
As far as I remember caddy recommends to use "client_ip" field rather than "remote_ip" for the addons. that might be the case.
Will have to explore how to extract the client_ip
somehow provided by Caddy instead, any pointer would be appreciated!
Related issue: https://caddy.community/t/getting-real-ip-with-caddy-behind-a-reverse-proxy/24518
That's my post on caddy community I was able to solve the issue by making some small changes to http.go, you can see the commits on my fork here
Hey @samdelong, thanks for chiming in. I see that your solution is based on X-Real-IP
which looks like it has to be explicitly configured (https://caddy.community/t/how-to-add-x-real-ip-header/11172). Is it something you configured in your Caddy config? Could there be a solution based on X-Forwarded-For
that according to https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#defaults is always present?
I didn't have to add anything to my Caddyfile config. I dont have any PRs to reference, but since that post was from 3 years ago its seems the X-Real-IP
header is forwarded by default now. Ideally the solution would check for both headers
I am running caddy and cloudflared in containers. I expose the app through cloudflare tunnel. Even though I see correct IP address for the user in the client_ip field in caddy HTTP access logs, I only see my local IP where my cloudflared container is running in "client" field in coraza's logs.
In caddy logs, remote_ip field refers to 172.19.0.2 (my local cloudflared) As far as I remember caddy recommends to use "client_ip" field rather than "remote_ip" for the addons. that might be the case.