Nginx generally sets up and processes HTTP requests, sends function calls, and various phase statuses (and other improvements)

Source: Internet
Author: User

 

The Calling relationship is too complicated. Every function has done a lot of things, and the detailed process is free to write.

 

// When the current connection is over: ngx_http_init_connection will be called

Ngx_http_init_connection-> ngx_http_init_request-> ngx_http_process_request_line->

Ngx_http_process_request_headers-> ngx_http_process_request-> ngx_http_handler->

Ngx_http_core_run_phases-> ngx_http_core_find_config_phase (content handler will be updated)->

Ngx_http_core_content_phase-> Handler-> (two requests are called to complete ngx_http_send_header and ngx_http_output_filter)

 

// Send the response header. The last ngx_http_header_filter will call ngx_http_write_filter to send the response header.

Ngx_http_send_header-> ngx_http_top_header_filter-> *** our fileter ***-> ngx_http_header_filter->

Ngx_http_write_filter-> ngx_send_chain (send_chain) is ngx_writev_chain

 

// Send the response body

Ngx_http_output_filter-> ***** our filter *****-> ngx_http_write_filter-> ngx_send_chain (send_chain) is ngx_writev_chain

Each stage may have multiple handler, which are stored in phase_engine. The classification and storage in phase are saved in sequence. The call parsing for one stage and one stage is called: ngx_http_core_generic_phasehandler, which corresponds to each handler in phase. Next: point to the next phase, that is, Handler: corresponds to each handler in phase next: points to the next phase, that is, Handler: No next: No ngx_http_rewrite_phasechecker: ngx_http_core_generic_phasehandler: next corresponds to each handler in phase: pointing to the next phase, that is, handler (if rewrite is used) Checker: Handler: None next: pointing to handler: ngx_http_core_generic_phasehandler: corresponding to next for each handler in phase: point to the next phase, that is, handler (N adds one more) Checker: ngx_http_core_access_phasehandler: corresponds to each handler in phase next: points to the next phase, that is, ngx_http_try_files_phase) ngx_http_post_access_phase (if access is used) Checker: marker: No next: points to the next phase, that is, Handler: Failed: No next: No ngx_http_content_phasechecker: Next: corresponds to each handler in phase: point to the next phase, that is, ngx_http_log_phasengx_http_log_phasechecker: ngx_http_core_generic_phasehandler: Next to each handler in the phase, pointing to the next phase, null

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.