国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > Nginx > 正文

Nginx實現瀏覽器可實時查看訪問日志的步驟詳解

2024-08-30 12:28:14
字體:
來源:轉載
供稿:網友

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

[root@AnSheng ~]# /application/nginx-1.9.7/sbin/nginx -Vnginx version: nginx/1.9.7built 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

二、檢查語法并啟動nginx

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

三、把nginx配置文件內多余的注視行和空行刪掉

[root@AnSheng ~]# cd /application/nginx-1.9.7/conf/[root@AnSheng conf]# egrep -v "#|^$" nginx.conf.defaultworker_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標簽內加入以下標簽和內容

location /logs { alias /application/nginx-1.9.7/logs; #Nginx日志目錄 autoindex on; #打開目錄瀏覽功能 autoindex_exact_size off; #默認為on,顯示出文件的確切大小,單位是bytes #顯示出文件的大概大小,單位是kB或者MB或者GB autoindex_localtime on; #默認為off,顯示的文件時間為GMT時間。 #改為on后,顯示的文件時間為文件的服務器時間 add_header Cache-Control no-store; #讓瀏覽器不保存臨時文件}

五、開啟在瀏覽器打開log文件,如果不開啟再點擊文件的時候就下載而不是打開

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

六、檢測語法,然后讓nginx配置生效,在瀏覽器查看

[root@AnSheng conf]# /application/nginx-1.9.7/sbin/nginx -tnginx: the configuration file /application/nginx-1.9.7/conf/nginx.conf syntax is oknginx: 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,然后點擊文件就可以打開了,如果日志隨隨便便就可以被別人查看是不是很不安全,所以我們要在加一層nginx用戶認證。

nginx,訪問日志,實時日志監控,日志實時分析

nginx,訪問日志,實時日志監控,日志實時分析

七、安裝httpd-tools,用于帳號密碼生成

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

八、創建認證的賬號

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

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

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

十、然后再打開的時候就會提示輸入賬號和密碼,登陸之后才可以查看。

nginx,訪問日志,實時日志監控,日志實時分析

十一、總結

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 泾川县| 哈密市| 城步| 广安市| 莆田市| 阿拉善左旗| 钟祥市| 五家渠市| 托里县| 长垣县| 东兰县| 珲春市| 青海省| 于田县| 康乐县| 黄陵县| 梁河县| 安陆市| 仙游县| 工布江达县| 瑞金市| 平定县| 高碑店市| 金昌市| 南陵县| 靖边县| 厦门市| 敦煌市| 九龙城区| 台山市| 绵竹市| 文安县| 郑州市| 兴海县| 囊谦县| 余江县| 和田县| 南开区| 栖霞市| 台南县| 梁河县|