Map variables to $clientIP with regex.
Webserver behind multiple CDN, The custom header with the client's real ip varies. So I came out with the follow expression.
#here I use @ as seperator
map "$http_cf_connecting_ip@$http_cdn_src_ip@$http_src_ip@$http_client_ip" $clientIP {
"~[^-]+@-@-@-$" $http_cf_connecting_ip;
"~^-@[^-]+@-@-$" $http_cdn_src_ip;
"~^-@-@[^-]+@-$" $http_src_ip;
"~^-@-@-@[^-]+$" $http_client_ip;
"~^-@-@-@-$" $remote_addr;
default $remote_addr;
}
I use postman to send custom http headers. But seems map will always go to default.