Nginx Map how to check value if empty

Francis Daly francis at daoine.org
Sat Mar 4 08:14:33 UTC 2017


On Fri, Mar 03, 2017 at 10:47:26AM -0500, c0nw0nk wrote:

Hi there,

> map $http_cf_connecting_ip $client_ip_from_cf {
> default $http_cf_connecting_ip;
> }
> 
> How can I make it so if the client did not send that $http_ header it makes
> $client_ip_from_cf variable value = $binary_remote_addr
> 
> Not sure how to check in a map if that http header is present.

If the http header is absent, the matching variable is empty. So it will
have the value "".

Use that as the first half of your "map" pair.

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list