公司的监控系统使用的nagios,而外网访问nagios使用的域名形式。内网使用nginx进行反向代理到nagios所在的服务器。
nginx的反向代理与域名配置如下:
[root@lzmail vhosts]# more test.ilanni.com.conf
server
{
listen 80;
server_name test.ilanni.com;
index index.html index.htm index.php index.cgi;
location /nagios{
proxy_pass http://192.168.0.1:81/nagios/;
}
proxy_set_header x-real-ip $remote_addr;
proxy_set_header remote-host $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
access_log /var/log/test.ilanni.com.log main;
今天没事就看看nagios日志记录相关的信息,分析用户的行为。
我们可以通过tail –f /var/log/test.ilanni.com动态分析。

120.204.200.21 – – [07/jun/2014:17:21:17 +0800] get / http/1.1 “200” 555 “-” “dnspod-monitor/1.0” “-”
101.71.38.76 – nagiosadmin [07/jun/2014:17:21:26 +0800] get /nagios/cgi-bin/extinfo.cgi?type=2&host=gs_1.11mail&service=check_cpu http/1.1 “200” 2709 “-” “mozilla/5.0 (compatible; msie 10.0; windows nt 6.2; wow64; trident/6.0)” “-”
101.71.37.62 – nagiosadmin [07/jun/2014:17:21:26 +0800] get /nagios/stylesheets/common.css http/1.1 “304” 0 “http://test.ilanni.com/nagios/cgi-bin/extinfo.cgi?type=2&host=gs_1.11mail&service=check_cpu” “mozilla/5.0 (compatible; msie 10.0; windows nt 6.2; wow64; trident/6.0)” “-“
以上是这个日志的其中一条记录。
101.71.37.62记录的访问者的ip地址,这个是通过nginx的反向代理配置中的proxy_set_header x-real-ip $remote_addr;获得。
nagiosadmin记录的是远程用户。
这个ip地址其实我自己,而我目前访问的网页是nagios监控一个主机的cpu项目,如下:
get /nagios/stylesheets/common.css http/1.1 “304” 0 “http://test.ilanni.com/nagios/cgi-bin/extinfo.cgi?type=2&host=gs_1.11mail&service=check_cpu“
这个记录的是用户正在访问的网页。对比我上边的访问网页截图,很容易能看到我访问的确实是主机192.168.1.11的cpu监控项。
继续向下看:
mozilla/5.0 (compatible; msie 10.0; windows nt 6.2; wow64; trident/6.0)
这个记录的是访问者浏览器及操作系统的相关信息。
其中msie 10表示通过ie 10进行访问的。这个和我本机的ie 10刚好相符,如下:
windows nt 6.2表示访问者使用的是os版本,nt6.2是win8系统。
而我的本本确实是win8系统,内核版本确实是nt 6.2,如下图:
wow64表示os是64bit系统,本本的系统版本如下图:
通过上述分析,我们可以得到如下的信息:
nagiosadmin用户使用win8 64bit系统通过ie10浏览器正在访问nagios的一个check_cpu监控项目。