Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx log

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The ngx_http_log_module module is responsible for logging:

= default nginx log

Log_format main'$remote_addr-$remote_user [$time_local] "$request"'

'$status $body_bytes_sent "$http_referer"'

'"$http_user_agent"$http_x_forwarded_for"'

Effect 1:

192.168.11.12-[01/Feb/2018:10:12:05 + 0800] "HEAD / ss HTTP/1.1" 2000 "-" curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh3/1.4.2 "

= Custom nginx log

Log_format access'$remote_addr-"$host"$hostname" [$time_local]'

'"$request" $status $bytes_sent $body_bytes_sent $request_time'

'"$http_referer"$http_user_agent" $server_addr "

'"$http_range" $upstream_response_time "$upstream_addr" $upstream_status $upstream_http_Isure_Upstream_Time'

Effect 1:

192.168.11.12-"www.web2.com", "dev-2" [01/Feb/2018:10:36:54 + 0800] "GET / ss/gskhsk HTTP/1.1" 200 235 39 0.001 "-" curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh3/1.4.2 "192.168.11.12 "-" 0.001 "127.0.0.1 9000" 200-

Effect 2:

192.168.11.188-"www.web2.com", "dev-2" [01/Feb/2018:10:40:42 + 0800] "GET http://www.web2.com/ss/gskhsk HTTP/1.1" 200235 39 0.001 "-" curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.19.1 Basic ECC zlib/1.2.3 libidn/1.18 libssh3/1. 4.2 "192.168.11.12"-"0.001" 127.0.0.1 9000 "200-

Configuration:

Access_log / logs/nginx/access.log access

Log_format format variables:

$remote_addr # record the client address of visiting the website $remote_user # remote client user name $time_local # record the access time and time zone $request # the http request departure information of the user $status # http status code, record the status code returned by the request For example, the number of response body bytes sent to the client by $body_bytes_sent # server $http_referer # records the connection from which the request is accessed, and hotlink protection can be set according to this parameter. $http_user_agent # record client access information, for example: browser, mobile client, etc. $http_x_forwarded_for # when there is a proxy server at the current end, set the web node to record the configuration of the client address. This parameter takes effect only if the proxy server also makes relevant x_forwarded_for settings.

Test: curl-I "http://web2.com?name=yeqing&age=18"-x 192.168.11.1280

Note: service nginx restart is required to customize the log.

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report