nginx - 什么时候在 NGINX 上计算变量
问题描述
声明新变量(例如map
geoIP2 或 geoIP2)总是在http
上下文中。
假设我只需要在配置中的某个location
块上检查 ip 的位置,这是否意味着与 geoIP2 相关的这些变量将在与服务器建立的任何连接中或仅在其被调用时计算?
我想知道 NGINX 是如何工作的,什么时候计算变量?
例子:
http{
geoip2 GeoIP/GeoLite2-Country.mmdb {
$geoip2Country country iso_code;
}
map $geoip2Country $denyCountry {
default 1;
US 0;
}
location /zone/{ //the only location where I use the variable
if ($denyCountry){
return 444;
}
}
}
解决方案
推荐阅读
- reactjs - 状态并不总是更新
- macos - auval:错误:类数据没有必填字段:
== 组件类型 - console - F9 在 Spyder 中执行选定的文本?
- ruby-on-rails - Ruby on Rails 表单与表中的 collection_check_boxes - has_and_belongs_to_many 关联
- javascript - 在渲染组件之前根据其 id 设置默认活动项
- ios - 未从 JSON Swift 获取数据
- sql - 如何从具有相同 ID 的多行中获取单行?
- html - 为不同的屏幕尺寸保留屏幕尺寸
- python - 解析来自 Boto3 Cost Explorer 客户端的 AWS Lambda Python 函数响应
- c# - 如何绑定到容器以遍历 blob