This article mainly introduces the operation and maintenance of the LNMP tracking, has a certain reference value, now share to everyone, the need for friends can refer to
Summary of LNMP's operation and maintenance tracking skills
Once upon a time I began to LNMP company's website, after a period of scraping, but also summed up a lot in the LNMP server debug tracking various Web site error methods. Good memory is better than bad writing, or summarize it!
At the beginning, I'll comb through what I understand. A Web request has been made by the server and browser in each phase of the response. So the user response exception occurs in this process, knowing that the details of each process can be used in different ways to locate the phase of the anomaly, so that more accurate and rapid positioning of the error. The following is a continuous update I was tortured by the site of the various mistakes, to make a record, of course, if you can help others, I am also honored.
What happened in the process of a Web request?
is a simple Web request the whole process, well, the painting is indeed a little too simple, I hide a lot of details, below one by one notes, may have not been involved in the place Welcome to add:
The first step
The user enters a URL such as http:www.baidu.com to a browser, and the browser, such as Chrom, needs to resolve it to an IP address to know where to go to access the server. The browser resolves the DNS steps as follows:
Search the browser's own DNS cache, which has a short cache time and a limited number of caches.
Search the DNS cache for the operating system
Read the DNS mapping of the host file (usually local development mapping is to modify this file to intercept the browser request to the local server, so that the local can successfully map the server address)
First, the DNS server in the local network card configuration initiates the domain name resolution request, as if there is a set of operator processing flow is not expanded.
The following seems to have some process, because the basic will not perform to this step, generally so the DNS server will be fixed.
Parse failed, any one of these steps will return a successful IP address
Step Two
The browser initiates the famous TCP3 handshake with a specific port (default 80) with this IP address on a random port. The process of how an HTTP request arrives at the Nginx service is roughly as follows:
ST=>START:TCP Request En=>end: Exception Op=>operation:nginx Module cond1=>condition: Enter the NIC? Cond2=>condition: The TCP/IP protocol stack for the kernel? Cond3=>condition: Firewall? St->cond1cond1 (yes)->cond2cond1 (NO)->encond2 (yes)->cond3cond2 (NO) Encond3 (NO)->encond3 (yes)->op
Step Three
After the handshake completes the browser and the server can happily send the HTTP request, concrete on the Nginx process as follows:
St=>start:http Request En=>end:response Response op1=>operation: The second step process Op2=>operation:nginx process op3=>operation: Get header information for HTTP op4=>operation: Match server_name, navigate to the root of the site Op5=>operation: Route op6=>operation into the code framework: The framework's route resolver resolves the php file op7=>operation:php into the fastcgi process op8=>operation:fastcgi process to populate PHP with HTML files op9=>operation: HTML file submitted to Nginx and set the response information st->op1->op2->op3->op4->op5->op6->op7->op8->op9->en
Fourth Step
The browser renders a visual page based on the response head and response body of the server Resopnse
Response Code |
Description |
1xx |
Informational Status Description |
2xx |
Success Status Code |
3xx |
REDIRECT Status code |
301 |
Permanent redirect, the value of the location response header is still the current URL, so the redirect is hidden |
302 |
Temporary redirect, explicit redirect, location response header value for new URL |
304 |
Not Modified unmodified, such as the local cache resource file and the comparison on the server, the discovery has not been modified, the server returned a 304 status code, tell the browser, you do not have to request the resource, directly using local resources can |
4xx |
Client Error |
404 |
Not Found the requested URL resource does not exist |
5xx |
Server error |
500 |
Internal Server error Server internal errors |
502 |
Bad Gateway appears when the proxy server does not contact the backend server |
504 |
Gateway Timeout This is the server that the agent can contact to the backend, but the backend server does not respond to the proxy server for a specified period of time |
The above is the whole content of this article, I hope that everyone's learning has helped, more relevant content please pay attention to topic.alibabacloud.com!