请求body日志记录
自定义日志格式,使用 $request_body 变量:
http {log_format custom '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$request_body"';...}
在 server 或 location 块中使用自定义的日志格式:
server {...access_log /var/log/nginx/your_access.log custom;...}
请求头密钥验证
http {map $http_authorization $valid_token {default 0; # 默认情况下,令牌无效"Bearer xxx" 1; # 如果令牌匹配,则设置为有效,xxx一般为ak-加32位字符串,例如【Bearer ak-bjtq3nr4m74j2v8fy5j6qaes32h8888】}...}server {location / {# 检查Authorization头中的令牌是否有效if ($valid_token = 0) {return 403; # 返回403 Forbidden}...
