Table of Contents
1. Log introduction" >1. Log introduction
2. Access log" >2. Access log
Home Operation and Maintenance Nginx How to analyze nginx error log

How to analyze nginx error log

Jun 21, 2019 am 09:51 AM
nginx error log

How to analyze nginx error log

1. Log introduction

There are two main types of nginx logs: access logs and error logs. The access log mainly records every request from the client to access nginx, and the format can be customized; the error log mainly records the log when the client accesses nginx and an error occurs, and the format does not support customization. Both logs can be optionally turned off.

Through the access log, you can get relevant information such as the user’s geographical origin, jump source, terminal usage, number of visits to a certain URL; through the error log, you can You can get the performance bottleneck of a certain service or server in the system, etc. Therefore, by making good use of logs, you can get a lot of valuable information.

2. Access log

[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'

'$ Requesst_Time $ Upstream_time_time

##113.140.15.90##$remote_user$time_local$request##200##$body_bytes_sent#$http_refererThe address of the backgroundTotal time of the entire requestDuring the request process,
##Variable name

Variable description

Examples

##$remote_addr

Client address

Client user name

-

Visit Time and time zone

##18/Jul/2012:17:00:01 0800

Requested URI

and
HTTP

Protocol"GET /pa/img/home/logo-alipay-t.png HTTP/1.1 "

##$http_host

Request address, that is, the address you enter in the browser (IP or domain name)

img.alipay .com

10.253.70.103

##$status

HTTPRequest Status

##200

##$upstream_status

##upstream

Status

The size of the file content sent to the client

547

Jump source

"https://cashier.alip
ay.com.../"

#$http_user_agent

User Terminal Agent

"Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; GTB7.0; .NET4.0C ;

##$ssl_protocol

SSLProtocol Version

TLSv1

$ssl_cipher

##Algorithms in exchange data

RC4-SHA

##$upstream_addr

upstream, that is, the host address that actually provides services

10.228.35.247:80

#$request_time

0.205

$upstream_response_time

upstream

Response time

0.002

##

Online example:

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 test ($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/8/12-00:00:00&-T=+ 2880&-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"

How to analyze nginx error log

##Remarks: $http_referer is related to redirection.

Offline test ($http_host):

How to analyze nginx error log

Note: The value of $http_host is related to the value you enter in the browser.

3. Error log

( on the browser ##upstream##"upstream sent invalid header while reading response header from upstream"The response header sent is invalid"upstream sent no valid HTTP/1.0 header while reading response header from upstream"The response header sent is invalid"client intended to send too large body","reopening logs"command
Error message

Error description

"upstream prematurely(premature) closed connection"

The exception that occurs when requesting

uri is due to upstream It is caused by the user disconnecting when the response has not been returned to the user. It has no impact on the system and can be ignored

##"recv() failed (104: Connection reset by peer)"

1)server The number of concurrent connections exceeds its carrying capacity, and the server will Down drop some of the connections;

2)The client closed the browser, but the server is still sending data to the client; (

3) Press Stop

##"(111: Connection refused) while connecting to upstream"

When the user is connecting, if the user encounters the backend
upstream

hangs up or fails, and you will receive this error

"(111: Connection refused) while reading response header from upstream"

When users read data after a successful connection, if the backend upstream hangs or is blocked, they will receive this error

"(111: Connection refused) while sending request to upstream"

# When

##Nginx and upstream are successfully connected and sending data, if the backend upstream hangs or is blocked, You will receive the error

##"(110: Connection timed out) while connecting to upstream "

##nginx

Timeout when connecting to the following upstream

"(110: Connection timed out) while reading upstream"

nginx

Timed out while reading the response from upstream

"(110: Connection timed out) while reading response header from upstream"

nginx

Timeout while reading response headers from upstream

"(110: Connection timed out) while reading upstream"

nginx

Timed out while reading response from upstream

"(104: Connection reset by peer) while connecting to upstream"

Send

RST, reset the connection

upstream

upstream

is used to set the maximum value of client request content allowed to be accepted. The default value is

1M

clientThe body sent exceeds the set value

User sends

kill -USR1

"gracefully shutting down",

用户发送kill  -WINCH命令

"no servers are inside upstream"

upstream下未配置server

"no live upstreams while connecting to upstream"

upstream下的server全都挂了

"SSL_do_handshake() failed"

SSL握手失败

"SSL_write() failed (SSL:) while sending to client"

 

"(13: Permission denied) while reading upstream"

 

"(98: Address already in use) while connecting to upstream"

 

"(99: Cannot assign requested address) while connecting to upstream"

 

"ngx_slab_alloc() failed: no memory in SSL session shared cache"

ssl_session_cache大小不够等原因造成

"could not add new SSL session to the session cache while SSL handshaking"

ssl_session_cache大小不够等原因造成

"send() failed (111: Connection refused)"

 

 

For more Nginx related technical articles, please visit the Nginx Tutorial column to learn!

The above is the detailed content of How to analyze nginx error log. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to allow external network access to tomcat server How to allow external network access to tomcat server Apr 21, 2024 am 07:22 AM

To allow the Tomcat server to access the external network, you need to: modify the Tomcat configuration file to allow external connections. Add a firewall rule to allow access to the Tomcat server port. Create a DNS record pointing the domain name to the Tomcat server public IP. Optional: Use a reverse proxy to improve security and performance. Optional: Set up HTTPS for increased security.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Welcome to nginx!How to solve it? Welcome to nginx!How to solve it? Apr 17, 2024 am 05:12 AM

To solve the "Welcome to nginx!" error, you need to check the virtual host configuration, enable the virtual host, reload Nginx, if the virtual host configuration file cannot be found, create a default page and reload Nginx, then the error message will disappear and the website will be normal show.

How to communicate between docker containers How to communicate between docker containers Apr 07, 2024 pm 06:24 PM

There are five methods for container communication in the Docker environment: shared network, Docker Compose, network proxy, shared volume, and message queue. Depending on your isolation and security needs, choose the most appropriate communication method, such as leveraging Docker Compose to simplify connections or using a network proxy to increase isolation.

How to register phpmyadmin How to register phpmyadmin Apr 07, 2024 pm 02:45 PM

To register for phpMyAdmin, you need to first create a MySQL user and grant permissions to it, then download, install and configure phpMyAdmin, and finally log in to phpMyAdmin to manage the database.

How to deploy nodejs project to server How to deploy nodejs project to server Apr 21, 2024 am 04:40 AM

Server deployment steps for a Node.js project: Prepare the deployment environment: obtain server access, install Node.js, set up a Git repository. Build the application: Use npm run build to generate deployable code and dependencies. Upload code to the server: via Git or File Transfer Protocol. Install dependencies: SSH into the server and use npm install to install application dependencies. Start the application: Use a command such as node index.js to start the application, or use a process manager such as pm2. Configure a reverse proxy (optional): Use a reverse proxy such as Nginx or Apache to route traffic to your application

How to generate URL from html file How to generate URL from html file Apr 21, 2024 pm 12:57 PM

Converting an HTML file to a URL requires a web server, which involves the following steps: Obtain a web server. Set up a web server. Upload HTML file. Create a domain name. Route the request.

What to do if the installation of phpmyadmin fails What to do if the installation of phpmyadmin fails Apr 07, 2024 pm 03:15 PM

Troubleshooting steps for failed phpMyAdmin installation: Check system requirements (PHP version, MySQL version, web server); enable PHP extensions (mysqli, pdo_mysql, mbstring, token_get_all); check configuration file settings (host, port, username, password); Check file permissions (directory ownership, file permissions); check firewall settings (whitelist web server ports); view error logs (/var/log/apache2/error.log or /var/log/nginx/error.log); seek Technical support (phpMyAdmin

See all articles