注意XSS
记录日志一定要转义展示避免被xss
在 nginx 配置文件的 http{} 里面 增加
# ========== 新增开始 ==========
log_format full_log_format '$time_local [$remote_addr] [$http_x_forwarded_for] '
'$request_method $scheme://$host$request_uri $server_protocol '
'status:$status body_bytes:$body_bytes_sent '
'referer:"$http_referer" user_agent:"$http_user_agent" '
'request_time:$request_time upstream_connect_time:$upstream_connect_time '
'upstream_response_time:$upstream_response_time '
'cookie:"$http_cookie" host:$host server_port:$server_port';
# ========== 新增结束 ==========基础信息:$time_local(本地时间)、$remote_addr(客户端 IP)、$http_x_forwarded_for(代理 IP);
请求信息:$request_method(GET/POST 等)、$request_uri(请求路径)、$server_protocol(HTTP 协议版本);
响应信息:$status(状态码)、$body_bytes_sent(响应大小);
客户端信息:$http_referer(来源页)、$http_user_agent(客户端浏览器 / 设备)、$http_cookie(Cookie);
性能信息:$request_time(总请求耗时)、$upstream_connect_time(上游服务连接耗时)、$upstream_response_time(上游服务响应耗时);
服务信息:$host(域名)、$server_port(端口)
在 网站配置文件 修改 日志
日志文件后面加上 full_log_format
access_log /www/wwwlogs/xxxx.com.log full_log_format;
评论