Nginx 中用map 语句来判断某个header field是否存在

如果一个header field不存在,那么他的值为””. 这种方式仅在header中出现.

所以我们可以用下面的方式来判断某个header field是否存在.

map $http_cf_connecting_ip $client_ip_from_cf {
default $http_cf_connecting_ip;
"" $remote_addr;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.