为了ban人而设置的

map里技
https://chatgpt.com/share/9937d15c-6a91-426c-9544-6776df353bcb

官方文档
https://docs.nginx.com/nginx/admin-guide/monitoring/logging/
https://nginx.org/en/docs/http/ngx_http_map_module.html

技能来源
https://stackoverflow.com/questions/69836892/nginx-block-all-traffic-with-specific-custom-header-except-to-some-urls

# 在 http namespace
map $http_cf_ipcountry $block {
    'CN'     0;
    ''       0;
    default  $endpoint;
}

map $uri $endpoint {
    /ame/    1;
    /ame     1;
    default  0;
}

# 在 server namespace
if ($block) { return 403; }
```conf

# 附:debug技巧
```conf
log_format custom_log '$http_x_forwarded_for - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$uri"';

log_format custom_debug '$remote_addr - $remote_user [$time_local] "$request"'
'http_cf_ipcountry=$http_cf_ipcountry endpoint=$endpoint uri=$uri block=$block';

加入这样的debug

在access_log之后。 error_log后面是等级,不能用这个。

include 有顺序

不能重复

map反倒没有,气死我了