The ngx_upstream related structure of the notes of "deep understanding Nginx" __nginx

Source: Internet
Author: User
the meaning of the ngx_http_upstream_t data structure
typedef struct NGX_HTTP_UPSTREAM_S ngx_http_upstream_t;

    struct NGX_HTTP_UPSTREAM_S {//handler callback function for read events ngx_http_upstream_handler_pt Read_event_handler;

     A callback function that handles write events ngx_http_upstream_handler_pt Write_event_handler;

     Initiate a connection to upstream server ngx_peer_connection_t peer; /* When a response is forwarded to a downstream server, if the cache is turned on and the upstream speed is considered to be faster, the pipe member is used to forward the response. At this point, the pipe must be constructed beforehand by the HTTP module.

    * * ngx_event_pipe_t *pipe;

     Ngx_chain_t *request_bufs;
    Defines the way to send a response downstream ngx_output_chain_ctx_t output;

     ngx_chain_writer_ctx_t writer;
Various configurations ngx_http_upstream_conf_t *conf when using the upstream mechanism;
#if (Ngx_http_cache) ngx_array_t *caches; #endif/* You want upstream to forward the response directly, you need to fit the resolved response head in the Process_header function to the HTTP response head, and you need to set the information in the header to the header_in structure. ngx_

     Http_upstream_headers_in_t headers_in;

    Used to resolve the host domain name ngx_http_upstream_resolved_t *resolved;                      ngx_buf_t  From_client;                        /* Receive the upstream server response to the packet header buffer, without the need to send the response directly to the client, or the buffering logo bit is 0 in the case of the transfer, receive the package body buffer still use buffer * */ngx_buf_t

    Buffer

     Indicates the length of the response package from the upstream server off_t lengths; /* Depending on two situations: 1. When the input_filter is not needed and the default method is used to handle the package, the OUT_BUFS points to the response packet; 2.

    When a transfer is required to the downstream, the list points to the previous downstream forwarding response to the cache response received from the upstream in the current period; * * ngx_chain_t *out_bufs;

    /* When a response package is required to be forwarded downstream, it represents the content that was not sent when the response was last forwarded to downstream * * * ngx_chain_t *busy_bufs;

     Used to recycle the ngx_buf_t structure ngx_chain_t *FREE_BUFS which has been sent to downstream in Out_bufs;

    The initialization method ngx_int_t (*input_filter_init) (void *data) before handling the package body;

    Methods of handling Inclusions ngx_int_t (*input_filter) (void *data, ssize_t bytes);

Used to pass the HTTP module custom data structure, in the above two functions as parameters to pass void *input_filter_ctx;
#if (Ngx_http_cache) ngx_int_t (*create_key) (ngx_http_request_t *r); #endif//HTTP module implementation to construct the function of the request to the upstream server ngx_int_t (*create_request) (ngx_http_request_t *r);

    After communication with the upstream server fails, reboot the connection ngx_int_t (*reinit_request) (ngx_http_request_t *r);
    Resolves the header ngx_int_t (*process_header) (ngx_http_request_t *r) in which the upstream server returns the response;

    void (*abort_request) (ngx_http_request_t *r);
                                         call void (*finalize_request) at the end of the request (ngx_http_request_t *r,

    ngx_int_t RC);
                                         The redirect function ngx_int_t (*rewrite_redirect) (ngx_http_request_t *r) that can be implemented by the HTTP module
    ngx_table_elt_t *h, size_t prefix); ngx_int_t (*rewrite_cookie) (ngx_http_request_t *r, ngx_table

    _elt_t *h);

     ngx_msec_t timeout;

     The error code of upstream response, the length of package body and other information ngx_http_upstream_state_t *state; Useful when using file caching ngx_str_t                        Method
    Useful ngx_str_t schema when logging;

ngx_str_t URI;
#if (NGX_HTTP_SSL) ngx_str_t ssl_name;

     #endif//temporarily corresponds to a ngx_http_cleanup_pt *cleanup indicating whether or not to clean up resources;
    Whether to specify a cache path unsigned store:1;
    Whether to enable file caching unsigned cacheable:1;
    unsigned accel:1;
Whether to access upstream server unsigned ssl:1 based on SSL protocol;
#if (ngx_http_cache) unsigned cache_status:3;
    When forwarding upstream packages #endif//downstream, open larger memory and temporary disk files for caching unsigned buffering:1;
    unsigned keepalive:1;

     unsigned upgrade:1;

    Indicates whether the request has been sent to the upstream server unsigned request_sent:1;
Indicates whether to forward the header to the client unsigned header_sent:1;
 };
ngx_http_upstream_conf_t

This structure specifies how the upstream is run. It must be set before starting the upstream mechanism.

typedef struct {/* When resolved members are not implemented in ngx_http_upstream_t, this variable will not take effect to define the configuration of the upstream server * * Ngx_http_upstream_srv_con

     f_t *upstream;

    The timeout for establishing a TCP connection is actually the timeout period set when the write event is added to the timer ngx_msec_t connect_timeout;

    Send request timeout, usually the timeout time set in the timer added by write event ngx_msec_t Send_timeout;
    The time-out period for receiving the response, usually the timeout set in the timer added by the Read event ngx_msec_t Read_timeout;
    ngx_msec_t timeout;

     ngx_msec_t next_upstream_timeout;

    The TCP So_snolowat option, which indicates the lower bound of the send buffer size_t Send_lowat;
    Defines the buffer size of the receiving head (buffer buffers in ngx_http_upstream_t) size_t buffer_size;

     size_t Limit_rate;

    When buffering=1, and forwarding the response downstream size_t Busy_buffers_size;

    Buffering=1, if the upstream speed is faster than downstream, it may be the upstream response to the temporary file in the temporary file size size_t max_temp_file_size; Character stream maximum length size to write temporary files at a time_t temp_file_write_size;
    size_t busy_buffers_size_conf;
    size_t max_temp_file_size_conf;

     size_t temp_file_write_size_conf;

     The amount of memory used to forward the package of the upstream server in a cached response is ngx_bufs_t bufs;

    For HEADER_IN members in ngx_http_upstream_t, Ignore_headers can skip some head ngx_uint_t ignore_headers based on bit operations;

    Some error codes are represented in binary notation, and the new upstream server ngx_uint_t Next_upstream is selected based on these error codes;
    Represents the directory that was created, the permissions of the file ngx_uint_t store_access;

    ngx_uint_t next_upstream_tries;                       /* To determine the forwarding response of the flag bit 1: think upstream faster than downstream, will try to cache in memory or disk from upstream response; 0: Only a fixed sized block of memory is opened as a cache to forward the response. * ngx_flag_t
    Buffering;
    ngx_flag_t request_buffering;
    ngx_flag_t pass_request_headers;

     ngx_flag_t Pass_request_body; 1: Upstream server interaction does not check whetherDisconnect from downstream clients and continue to perform interactive content ngx_flag_t Ignore_client_abort;

    Intercept the error code to see if there is a corresponding semantic ngx_flag_t intercept_errors that can be returned;
    1: Attempts to reuse the space ngx_flag_t cyclic_temp_file that have already been used in the temporary document;

     ngx_flag_t force_ranges;

     The path that holds the temporary file ngx_path_t *temp_path;

    A hidden HTTP header hash list is constructed according to the Ngx_http_upstream_hide_headers_hash function ngx_hash_t Hide_headers_hash;

    Do not want to forward the head ngx_array_t *hide_headers;

     Clearly want to forward the head ngx_array_t *pass_headers;

The native address ngx_http_upstream_local_t *local when the upstream server is connected;
    #if (Ngx_http_cache) ngx_shm_zone_t *cache_zone;

    ngx_http_complex_value_t *cache_value;
    ngx_uint_t cache_min_uses;
    ngx_uint_t Cache_use_stale;

    ngx_uint_t Cache_methods;              ngx_flag_t         Cache_lock;
    ngx_msec_t cache_lock_timeout;

    ngx_msec_t Cache_lock_age;

    ngx_flag_t cache_revalidate;
    ngx_array_t *cache_valid;
    ngx_array_t *cache_bypass;
ngx_array_t *no_cache;
    #endif//Indicates the length of the store path ngx_array_t *store_lengths;

Represents the storage path ngx_array_t *store_values;
#if (Ngx_http_cache) signed Cache:2;

    #endif//Signed Store:2 as the store in ngx_http_upstream_t;

    1: Capture to 404 direct forwarding unsigned intercept_404:1; /* 1: Used to dynamically determine the buffering flag bit. According to the value of x-accel-buffering (yes/no) in the headers_in of ngx_http_upstream_t, buffering/unsigned cha

Nge_buffering:1;
    #if (NGX_HTTP_SSL) ngx_ssl_t *ssl;
ngx_flag_t Ssl_session_reuse;
    ngx_http_complex_value_t *ssl_name;
    ngx_flag_t Ssl_server_name;
ngx_flag_t ssl_verify;
#endif//using upstream module name only for log ngx_str_t module; } ngx_http_upstream_conf_t;

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.