1. nginx logs include access logs and error logs. Access logs mainly record every request from the client to access nginx. The format can be customized. The error logs mainly record the logs when an error occurs when the client accesses nginx. The format cannot be customized. You can disable both types of logs. You can obtain
1. nginx logs include access logs and error logs. Access logs mainly record every request from the client to access nginx. The format can be customized. The error logs mainly record the logs when an error occurs when the client accesses nginx. The format cannot be customized. You can disable both types of logs. You can obtain
1, Log Introduction
There are two main types of nginx logs: access logs andErrorLogs. Access logs record every request from the client to access nginx in a custom format;ErrorLogs mainly record the logs when an error occurs when the client accesses nginx. The format cannot be customized. You can disable both types of logs.
By using access logs, you can obtain information about the user's region source, jump source, terminal, or URL access.ErrorLog, you can get the performance bottleneck of a system service or server. Therefore, you can get a lot of valuable information by making full use of logs.
2. Access logs
[Access. log]
Log_format main '$ remote_addr
$ Remote_user [$ time_local] "$ request" $ http_host'
'$ Status $ upstream_status
$ Body_bytes_sent "$ http_referer "'
'"$ Http_user_agent"
$ Ssl_protocol $ ssl_cipher $ upstream_addr'
'$ Request_time
$ Upstream_response_time ';
Variable name |
Variable description |
Example |
$ Remote_addr |
Client address |
113.140.15.90 |
$ Remote_user |
Client User Name |
- |
$ Time_local |
Access time and time zone |
18/Jul/2012: 17: 00: 01 + 0800 |
$ Request |
Request URI and HTTP protocol |
"GET /Pa/img/home/logo-alipay-t.png HTTP/1.1" |
$ Http_host |
Request address, that is, the address you entered in the browser (IP address or domain name) |
Img.alipay.com
10.253.70.103 |
$ Status |
HTTP Request status |
200 |
$ Upstream_status |
Upstream status |
200 |
$ Body_bytes_sent |
Size of the file sent to the client |
547 |
$ Http_referer |
Jump Source |
Https://cashier.alipay.com .../" |
$ Http_user_agent |
User Terminal proxy |
"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; . NET4.0C; |
$ Ssl_protocol |
SSL protocol version |
TLSv1 |
$ Ssl_cipher |
Algorithms in data exchange |
RC4-SHA |
$ Upstream_addr |
The backend upstream address, that is, the host address that actually provides services |
10.228.35.247: 80 |
$ Request_time |
Total Request time |
0.205 |
$ Upstream_response_time |
Upstream response time during request |
0.002 |
Online instances:
116.9.137.90-
[02/Aug/2012: 14: 47: 12 + 0800] "GET/images/XX/20100324752729.png HTTP/1.1" img.alipay.com 200 200 2038 https://cashier.alipay.com/XX/PaymentResult.htm? PayNo = XX & outBizNo = 2012XX "Mozilla/4.0
(Compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2;. net clr 2.0.50727;
. Net clr 3.5.30729;. net clr 3.0.30729; Media Center PC 6.0; Tablet PC 2.0;
360SE) "TLSv1 AES128-SHA 10.228.21.237: 80 0.198 0.001
Offline testing ($ Http_referer):
10.14.21.197 --
[14/Aug/2012: 17: 28: 22 + 0800] "GET
/Spanner/watch/v1? -- Db = ztg-1 & -- mode = compare & -- index = status & -- option = & -- cluster = whole &-F = 2012% 2F8% 2F12-00% 3A00% 3A00 &-T = % 2B2880 &-I = 1 &-n = 0 & _ = 1344936501292
HTTP/1.1 "200 94193" http://spanner.alipay.net/optionFrame/history.html"
"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko)
Chrome/21.0.1180.60 Safari/537.1"
Note:$ Http_referer is related to redirection.
Offline testing ($ Http_host):
Note:The value of $ http_host is related to the value you entered in your browser.
3,
ErrorLogs
ErrorInformation |
ErrorDescription |
"Upstream prematurely (premature) closed connection" |
An exception occurs when a uri is requested because the user breaks the connection when upstream does not return a response to the user. This does not affect the system and can be ignored. |
"Recv () failed (104: Connection reset Peer )" |
(1) when the number of concurrent connections on the server exceeds its capacity, the server will shut Down some of the connections;
(2) The client closes the browser, and the server is still sending data to the client;
(3) the browser presses Stop. |
"(111: Connection refused) while connecting Upstream" |
If the backend upstream fails or fails during connection, the user will receiveError |
"(111: Connection refused) while reading response header From upstream" |
When the user reads data after the connection is successful, if the backend upstream fails or fails, the user will receiveError |
"(111: Connection refused) while sending request Upstream" |
When sending data after successful connection between Nginx and upstream, if the backend upstream fails or fails,Error |
"(110: Connection timed out) while connecting Upstream" |
Timeout when nginx is connected to the next upstream |
"(110: Connection timed out) while reading Upstream" |
Nginx timeout when reading response from upstream
|
"(110: Connection timed out) while reading response Header from upstream" |
Nginx times out when reading response headers from upstream. |
"(110: Connection timed out) while reading Upstream" |
Nginx timeout when reading response from upstream |
"(104: Connection reset by peer) while connecting Upstream" |
Upstream sends the RST and resets the connection. |
"Upstream sent invalid header while reading response Header from upstream" |
The response header sent by upstream is invalid. |
"Upstream sent no valid HTTP/1.0 header while reading Response header from upstream" |
The response header sent by upstream is invalid. |
"Client intended to send too large Body" |
This parameter is used to set the maximum value of the client request content that can be accepted. The default value is 1 MB. The body sent by the client exceeds the set value. |
"Reopening logs" |
The user sends the kill-USR1 command |
"Gracefully shutting down ", |
The user sends the kill-WINCH command |
"No servers are inside upstream" |
Server not configured in upstream |
"No live upstreams while connecting Upstream" |
All servers under upstream are down |
"SSL_do_handshake () failed" |
SSL handshake failed |
"SSL_write () failed (SSL :) while sending Client" |
|
"(13: Permission denied) while reading Upstream" |
|
"(98: Address already in use) while connecting Upstream" |
|
"(99: Cannot assign requested address) while connecting To upstream" |
|
"Ngx_slab_alloc () failed: no memory in SSL session shared Cache" |
Ssl_session_cache size is insufficient |
"Cocould not add new SSL session to the session cache while SSL handshaking" |
Ssl_session_cache size is insufficient |
"Send () failed (111: Connection Refused )" |
|