nginx 服务器如何查看当前访问的域名

Song30 次浏览0个评论2025年06月10日

当我们网站被攻击时希望查看攻击从哪个域名而来,方便做其他处理;但是默认的日志不展示,所以我们需要自己开启一下。

vim /etc/nginx/nginx.conf 

然后在http中添加

log_format custom '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$server_name"';

然后设置日志格式为定义的custom:

 access_log /var/log/nginx/access.log custom;


更多相关好文