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
##Variable name
|
Variable description
| Examples
|
|||||||||||||||||||||||||||||||||||||||||||||||||||
##$remote_addr Client address |
##113.140.15.90 | ||||||||||||||||||||||||||||||||||||||||||||||||||||
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 | ##200||||||||||||||||||||||||||||||||||||||||||||||||||||
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" ##Remarks: $http_referer is related to redirection.
Offline test ($http_host): Note: The value of $http_host is related to the value you enter in the browser. 3. Error log
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!

Question: How to start Nginx? Answer: Install Nginx Startup Nginx Verification Nginx Is Nginx Started Explore other startup options Automatically start Nginx

How to confirm whether Nginx is started: 1. Use the command line: systemctl status nginx (Linux/Unix), netstat -ano | findstr 80 (Windows); 2. Check whether port 80 is open; 3. Check the Nginx startup message in the system log; 4. Use third-party tools, such as Nagios, Zabbix, and Icinga.

To shut down the Nginx service, follow these steps: Determine the installation type: Red Hat/CentOS (systemctl status nginx) or Debian/Ubuntu (service nginx status) Stop the service: Red Hat/CentOS (systemctl stop nginx) or Debian/Ubuntu (service nginx stop) Disable automatic startup (optional): Red Hat/CentOS (systemctl disabled nginx) or Debian/Ubuntu (syst

How to configure Nginx in Windows? Install Nginx and create a virtual host configuration. Modify the main configuration file and include the virtual host configuration. Start or reload Nginx. Test the configuration and view the website. Selectively enable SSL and configure SSL certificates. Selectively set the firewall to allow port 80 and 443 traffic.

The server does not have permission to access the requested resource, resulting in a nginx 403 error. Solutions include: Check file permissions. Check the .htaccess configuration. Check nginx configuration. Configure SELinux permissions. Check the firewall rules. Troubleshoot other causes such as browser problems, server failures, or other possible errors.

Steps to start Nginx in Linux: Check whether Nginx is installed. Use systemctl start nginx to start the Nginx service. Use systemctl enable nginx to enable automatic startup of Nginx at system startup. Use systemctl status nginx to verify that the startup is successful. Visit http://localhost in a web browser to view the default welcome page.

In Linux, use the following command to check whether Nginx is started: systemctl status nginx judges based on the command output: If "Active: active (running)" is displayed, Nginx is started. If "Active: inactive (dead)" is displayed, Nginx is stopped.

Answer to the question: 304 Not Modified error indicates that the browser has cached the latest resource version of the client request. Solution: 1. Clear the browser cache; 2. Disable the browser cache; 3. Configure Nginx to allow client cache; 4. Check file permissions; 5. Check file hash; 6. Disable CDN or reverse proxy cache; 7. Restart Nginx.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SublimeText3 Linux new version
SublimeText3 Linux latest version

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver CS6
Visual web development tools