Fixed conf error
This commit is contained in:
parent
e0e42ccafe
commit
68b25db0c2
50
nginx.conf
50
nginx.conf
@ -42,15 +42,47 @@ http {
|
||||
fe80::/10 0; # Link-local
|
||||
}
|
||||
|
||||
##
|
||||
# AI bot block map (optional; enforce in server with: if ($block_ai) { return 403; })
|
||||
##
|
||||
map $http_user_agent $block_ai {
|
||||
default 0;
|
||||
~*(GPTBot|ChatGPT-User|OAI-SearchBot|CCBot|Claude(Bot)?|PerplexityBot|Bytespider|Google-Extended|Amazonbot|DataForSeoBot|facebookexternalhit|DuckAssist|YouBot) 1;
|
||||
}
|
||||
|
||||
##
|
||||
# Logging (JSON)
|
||||
##
|
||||
log_format json escape=json
|
||||
'{ "time":"$time_iso8601", "remote_addr":"$remote_addr", "request":"$request", '
|
||||
'"status":$status, "body_bytes_sent":$body_bytes_sent, '
|
||||
'"referer":"$http_referer", "ua":"$http_user_agent", '
|
||||
'"request_time":$request_time, "upstream_time":"$upstream_response_time", '
|
||||
'"host":"$host", "uri":"$uri" }';
|
||||
'{'
|
||||
'"time":"$time_iso8601",'
|
||||
'"req_id":"$msec-$connection-$request_length",'
|
||||
'"is_external":$is_external,'
|
||||
'"is_ai_bot":$block_ai,'
|
||||
'"client_ip":"$remote_addr",'
|
||||
'"client_port":"$remote_port",'
|
||||
'"xff":"$http_x_forwarded_for",'
|
||||
'"scheme":"$scheme",'
|
||||
'"host":"$host",'
|
||||
'"method":"$request_method",'
|
||||
'"uri":"$uri",'
|
||||
'"query":"$query_string",'
|
||||
'"proto":"$server_protocol",'
|
||||
'"status":$status,'
|
||||
'"ref":"$http_referer",'
|
||||
'"ua":"$http_user_agent",'
|
||||
'"req_bytes":$request_length,'
|
||||
'"body_bytes_sent":$body_bytes_sent,'
|
||||
'"bytes_sent":$bytes_sent,'
|
||||
'"req_time":$request_time,'
|
||||
'"upstream_addr":"$upstream_addr",'
|
||||
'"upstream_status":"$upstream_status",'
|
||||
'"upstream_connect_time":"$upstream_connect_time",'
|
||||
'"upstream_header_time":"$upstream_header_time",'
|
||||
'"upstream_response_time":"$upstream_response_time",'
|
||||
'"ssl_protocol":"$ssl_protocol",'
|
||||
'"ssl_cipher":"$ssl_cipher"'
|
||||
'}';
|
||||
|
||||
access_log /var/log/nginx/access.json json if=$is_external;
|
||||
|
||||
@ -72,14 +104,6 @@ http {
|
||||
limit_req_zone $binary_remote_addr zone=api_rps:10m rate=5r/s;
|
||||
limit_conn_zone $binary_remote_addr zone=perip:10m;
|
||||
|
||||
##
|
||||
# AI bot block map (optional; enforce in server with: if ($block_ai) { return 403; })
|
||||
##
|
||||
map $http_user_agent $block_ai {
|
||||
default 0;
|
||||
~*(GPTBot|ChatGPT-User|OAI-SearchBot|CCBot|ClaudeBot|PerplexityBot) 1;
|
||||
}
|
||||
|
||||
##
|
||||
# Virtual Host Configs
|
||||
##
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user