In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how Nginx enables browsers to view access logs in real time". The explanation in this article is simple and clear and easy to learn and understand. please follow the editor's ideas to study and learn "Nginx how browsers can view access logs in real time".
First, check the nginx version. I am using the 1.9.7 version and the installation directory is in / 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
Check the syntax and start 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
Delete the superfluous watch lines and blank lines in the nginx configuration file
[root@ansheng ~] # cd / application/nginx-1.9.7/conf/ [root@ansheng conf] # egrep-v "# | ^ $" nginx.conf.defaultworker_processes 1 leading 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
Add the following tags and contents to the server tag of the nginx configuration file
Location / logs {alias / application/nginx-1.9.7/logs; # nginx log directory autoindex on; # Open directory browsing function autoindex_exact_size off; # defaults to on, showing the exact size of the file, in units of bytes # showing the approximate size of the file, in kb or mb or gb autoindex_localtime on; # default to off, and showing the file time in gmt time. # when changed to on, the file time displayed is the server time of the file add_header cache-control no-store; # so that the browser does not save the temporary file}
Open the log file in the browser. If you don't open the file, download it instead of opening it.
[root@ansheng conf] # vim mime.typestypes {text/html html htm shtml; text/log log; text/css css; text/xml xml;.
Check the syntax, and then let the nginx configuration take effect and view it in the browser.
[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
Open the browser to enter the domain name or ip, then add logs, and then click on the file to open it. If the log can be checked casually by others, it is not safe, so we need to add a layer of nginx user authentication.
7. Install httpd-tools for account password generation
[root@ansheng ~] # yum-y install httpd-tools
8. Create a certified account
[root@ansheng ~] # htpasswd-c / application/nginx-1.9.7/conf/loguser logusernew password:re-type new password:adding password for user loguser# password needs to be entered twice
Edit the nginx configuration file and add the following to the location of logs
Location / logs {. Alias path; autoindex on; autoindex_exact_size off; autoindex_localtime on; add_header cache-control no-store; auth_basic "restricted"; # nginx authentication auth_basic_user_file / application/nginx-1.9.7/conf/loguser; # authentication account password file}
Ten, and then when you open it, you will be prompted to enter your account number and password, and you can check it only after logging in.
Thank you for your reading, the above is the content of "Nginx how to realize the browser to view the access log in real time". After the study of this article, I believe you have a deeper understanding of how Nginx can be implemented by the browser to view the access log in real time, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.