最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Nginx實(shí)現(xiàn)瀏覽器可實(shí)時(shí)查看訪問日志的步驟詳解

 更新時(shí)間:2016年09月18日 11:45:37   投稿:daisy  
我們經(jīng)常需要在頁(yè)面上實(shí)時(shí)查看nginx的日志輸出,并且能在頁(yè)面上顯示,那么下面小編就給大家說下怎么在瀏覽器上實(shí)時(shí)動(dòng)態(tài)的查看nginx的訪問日志,有需要的朋友們可以參考借鑒。

一、首先查看nginx版本,我使用的是1.9.7的版本,安裝目錄在/application/nginx-1.9.7

[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx -V
nginx version: nginx/1.9.7
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
configure arguments: --prefix=/application/nginx-1.9.7 --user=nginx --group=nginx --with-http_stub_status_module

二、檢查語(yǔ)法并啟動(dòng)nginx

[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx -t
nginx: the configuration file /application/nginx-1.9.7/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.9.7/conf/nginx.conf test is successful
[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx

三、把nginx配置文件內(nèi)多余的注視行和空行刪掉

[root@AnSheng ~]# cd /application/nginx-1.9.7/conf/
[root@AnSheng conf]# egrep -v "#|^$" nginx.conf.default
worker_processes 1;
events {
 worker_connections 1024;
}
http {
 include mime.types;
 default_type application/octet-stream;
 sendfile on;
 keepalive_timeout 65;
 server {
  listen 80;
  server_name localhost;
  location / {
   root html;
   index index.html index.htm;
  }
  error_page 500 502 503 504 /50x.html;
  location = /50x.html {
   root html;
  }
 }
}
[root@AnSheng conf]# egrep -v "#|^$" nginx.conf.default nginx.conf

四、在nginx配置文件的server標(biāo)簽內(nèi)加入以下標(biāo)簽和內(nèi)容

location /logs {
 alias /application/nginx-1.9.7/logs;
 #Nginx日志目錄

 autoindex on;
 #打開目錄瀏覽功能

 autoindex_exact_size off;
 #默認(rèn)為on,顯示出文件的確切大小,單位是bytes
 #顯示出文件的大概大小,單位是kB或者M(jìn)B或者GB

 autoindex_localtime on;
 #默認(rèn)為off,顯示的文件時(shí)間為GMT時(shí)間。
 #改為on后,顯示的文件時(shí)間為文件的服務(wù)器時(shí)間

 add_header Cache-Control no-store;
 #讓瀏覽器不保存臨時(shí)文件
}

五、開啟在瀏覽器打開log文件,如果不開啟再點(diǎn)擊文件的時(shí)候就下載而不是打開

[root@AnSheng conf]# vim mime.types
types {
 text/html html htm shtml;
 text/log log;
 text/css css;
 text/xml xml;
 .............

六、檢測(cè)語(yǔ)法,然后讓nginx配置生效,在瀏覽器查看

[root@AnSheng conf]# /application/nginx-1.9.7/sbin/nginx -t
nginx: the configuration file /application/nginx-1.9.7/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.9.7/conf/nginx.conf test is successful
[root@AnSheng conf]# /application/nginx-1.9.7/sbin/nginx -s reload

打開瀏覽器輸入域名或者IP,后面加上logs,然后點(diǎn)擊文件就可以打開了,如果日志隨隨便便就可以被別人查看是不是很不安全,所以我們要在加一層nginx用戶認(rèn)證。

七、安裝httpd-tools,用于帳號(hào)密碼生成

[root@AnSheng ~]# yum -y install httpd-tools

八、創(chuàng)建認(rèn)證的賬號(hào)

[root@AnSheng ~]# htpasswd -c /application/nginx-1.9.7/conf/loguser loguser
New password:
Re-type new password:
Adding password for user loguser
#密碼需要輸入兩次

九、編輯nginx配置文件,在logs的location加入下面的內(nèi)容

location /logs {
 ......
 alias PATH;
 autoindex on;
 autoindex_exact_size off;
 autoindex_localtime on;
 add_header Cache-Control no-store;
 auth_basic "Restricted";
 #Nginx認(rèn)證
 auth_basic_user_file /application/nginx-1.9.7/conf/loguser;
 #認(rèn)證賬號(hào)密碼保存的文件
}

十、然后再打開的時(shí)候就會(huì)提示輸入賬號(hào)和密碼,登陸之后才可以查看。

十一、總結(jié)

以上就是利用Nginx實(shí)現(xiàn)瀏覽器可實(shí)時(shí)查看訪問日志的全部步驟,希望對(duì)大家的學(xué)習(xí)或者工作有所幫助,如果有疑問大家可以留言交流。

相關(guān)文章

最新評(píng)論

桂林市| 彭泽县| 北票市| 嘉兴市| 文水县| 新竹县| 炉霍县| 靖宇县| 铜川市| 闽清县| 贵定县| 土默特左旗| 宁强县| 东海县| 吴旗县| 行唐县| 蒙城县| 谢通门县| 会宁县| 通许县| 陕西省| 石楼县| 临泉县| 舞钢市| 海口市| 随州市| 潜江市| 长沙市| 平阴县| 波密县| 自贡市| 习水县| 苍梧县| 广水市| 茶陵县| 开封县| 芜湖市| 义乌市| 南昌县| 鹿泉市| 边坝县|