WeidiDeng / caddy-cloudflare-ip

Apache License 2.0
50 stars 2 forks source link

Example config in the README.md? #6

Open tonyhardcode opened 10 months ago

tonyhardcode commented 10 months ago

After some google searching I have not come across examples of using this plugin properly. After entering the trusted_proxies cloudflare under servers, how are we to implement the checking of cloudflare proxies for something like a reverse_proxy?

{
    http_port 80
    https_port 443

    servers {
        trusted_proxies cloudflare {
            interval 12h
            timeout 15s
        }
    }
}

domain.example.com {
    route {
        reverse_proxy 192.168.1.100:8080
    }
}
francislavoie commented 10 months ago

It's automatic. When enabling trusted proxies in global options, the HTTP server itself checks trust at the start of every request, then the reverse_proxy module pulls from the request context to check if trusted and if trusted it augments the X-Forwarded-* headers as appropriate.

Your config looks correct, I just recommend removing http_port/https_port because you're just re-stating the defaults which is not useful, plus you can remove route { because it doesn't do anything for you in this case.