国产xxxx99真实实拍_久久不雅视频_高清韩国a级特黄毛片_嗯老师别我我受不了了小说

資訊專欄INFORMATION COLUMN

nginx http模塊配置參數(shù)解讀

pf_miles / 1049人閱讀

摘要:名稱默認配置作用域官方說明中文解讀模塊是否開啟對后端的緩沖指定一個連接到代理服務(wù)器的超時時間,單位為秒,需要注意的是這個時間最好不要超過秒。

本文主要解析一下nginx http模塊配置參數(shù)。主要分socket相關(guān)參數(shù),對clinet請求的buffer參數(shù)以及對response的buffer參數(shù)。

socket
名稱 默認配置 作用域 官方說明 中文解讀 模塊
sendfile sendfile off; http, server, location, if in location Enables or disables the use of sendfile(). 設(shè)置為on可以啟用Linux上的sendfile系統(tǒng)調(diào)用來發(fā)送文件,它減少了內(nèi)核態(tài)與用戶態(tài)之間的兩次內(nèi)存復制,這樣就會從磁盤中讀取文件后直接在內(nèi)核態(tài)發(fā)送到網(wǎng)卡設(shè)備,提高了發(fā)送文件的效率。 ngx_http_core_module
tcp_nodelay tcp_nodelay on; http, server, location Enables or disables the use of the TCP_NODELAY option. The option is enabled only when a connection is transitioned into the keep-alive state. 對keepalive連接是否使用TCP_NODELAY選項,true的話,會禁用Nagle算法,盡快發(fā)送數(shù)據(jù),而不論包的大小。 ngx_http_core_module
tcp_nopush tcp_nopush off; http, server, location Enables or disables the use of the TCP_NOPUSH socket option on FreeBSD or the TCP_CORK socket option on Linux. The options are enabled only when sendfile is used. Enabling the option allows 1、sending the response header and the beginning of a file in one packet, on Linux and FreeBSD 4.x; 2、sending a file in full packets. 在打開sendfile選項時,確定是否開啟FreeBSD系統(tǒng)上的TCP_NOPUSH或Linux系統(tǒng)上的TCP_CORK功能。開啟此選項允許在Linux和FreeBSD 4.x上將響應(yīng)頭和正文的開始部分一起發(fā)送;一次性發(fā)送整個文件。 ngx_http_core_module
client buffer
名稱 默認配置 作用域 官方說明 中文解讀 模塊
keepalive_timeout keepalive_timeout 75s; http, server, location The first parameter sets a timeout during which a keep-alive client connection will stay open on the server side. The zero value disables keep-alive client connections. 一個keepalive連接在閑置超過一定時間后(默認的是75秒),服務(wù)器和瀏覽器都會去關(guān)閉這個連接。0表示禁用客戶端的keep-alive連接 ngx_http_core_module
client_header_timeout client_header_timeout 60s; http, server Defines a timeout for reading client request header. If a client does not transmit the entire header within this time, the 408 (Request Time-out) error is returned to the client. 客戶端與服務(wù)器建立連接后將開始接收HTTP頭部,在這個過程中,如果在一個時間間隔(超時時間)內(nèi)沒有讀取到客戶端發(fā)來的字節(jié),則認為超時,并向客戶端返回408(Request timed out)響應(yīng)。 ngx_http_core_module
client_body_timeout client_body_timeout 60s; http, server, location Defines a timeout for reading client request body. The timeout is set only for a period between two successive read operations, not for the transmission of the whole request body. If a client does not transmit anything within this time, the 408 (Request Time-out) error is returned to the client. 連續(xù)兩次讀取body的超時時間 ngx_http_core_module
send_timeout send_timeout 60s; http, server, location Sets a timeout for transmitting a response to the client. The timeout is set only between two successive write operations, not for the transmission of the whole response. If the client does not receive anything within this time, the connection is closed. 這個超時時間是發(fā)送響應(yīng)的超時時間,即Nginx服務(wù)器向客戶端發(fā)送了數(shù)據(jù)包,但客戶端一直沒有去接收這個數(shù)據(jù)包。如果某個連接超過send_timeout定義的超時時間,那么Nginx將會關(guān)閉這個連接。 ngx_http_core_module
client_header_buffer_size client_header_buffer_size 1k; http, server Sets buffer size for reading client request header. For most requests, a buffer of 1K bytes is enough. However, if a request includes long cookies, or comes from a WAP client, it may not fit into 1K. If a request line or a request header field does not fit into this buffer then larger buffers, configured by the large_client_header_buffers directive, are allocated. 定義了正常情況下Nginx接收用戶請求中HTTP header部分(包括HTTP行和HTTP頭部)時分配的內(nèi)存buffer大小。有時,請求中的HTTP header部分可能會超過這個大小,這時large_client_header_buffers定義的buffer將會生效。 ngx_http_core_module
large_client_header_buffers large_client_header_buffers 4 8k; http, server Sets the maximum number and size of buffers used for reading large client request header. A request line cannot exceed the size of one buffer, or the 414 (Request-URI Too Large) error is returned to the client. A request header field cannot exceed the size of one buffer as well, or the 400 (Bad Request) error is returned to the client. Buffers are allocated only on demand. By default, the buffer size is equal to 8K bytes. If after the end of request processing a connection is transitioned into the keep-alive state, these buffers are released. 定義了Nginx接收一個超大HTTP頭部請求的buffer個數(shù)和每個buffer的大小。如果HTTP請求行(如GET/index HTTP/1.1)的大小超過上面的單個buffer,則返回Request URI too large(414)。請求中一般會有許多header,每一個header的大小也不能超過單個buffer的大小,否則會返回Bad request(400)。當然,請求行和請求頭部的總和也不可以超過buffer個數(shù)*buffer大小。 ngx_http_core_module
client_max_body_size client_max_body_size 1m; http, server, location Sets the maximum allowed size of the client request body, specified in the “Content-Length” request header field. If the size in a request exceeds the configured value, the 413 (Request Entity Too Large) error is returned to the client. Please be aware that browsers cannot correctly display this error. Setting size to 0 disables checking of client request body size. 瀏覽器在發(fā)送含有較大HTTP包體的請求時,其頭部會有一個Content-Length字段,client_max_body_size是用來限制Content-Length所示值的大小的。因此,這個限制包體的配置非常有用處,因為不用等Nginx接收完所有的HTTP包體,這有可能消耗很長時間,就可以告訴用戶請求過大不被接受。例如,用戶試圖上傳一個10GB的文件,Nginx在收完包頭后,發(fā)現(xiàn)Content-Length超過client_max_body_size定義的值,就直接發(fā)送413(Request Entity Too Large)響應(yīng)給客戶端。 ngx_http_core_module
client_body_temp_path client_body_temp_path client_body_temp; http, server, location Defines a directory for storing temporary files holding client request bodies. Up to three-level subdirectory hierarchy can be used under the specified directory. For example, in the following configuration 用于指定臨時緩存文件的存儲路徑,這里需要注意的是proxy_temp_path和proxy_cache_path指定的路徑必須在同一磁盤分區(qū) ngx_http_core_module
client_body_buffer_size client_body_buffer_size 8k或16k; http, server, location Sets buffer size for reading client request body. In case the request body is larger than the buffer, the whole body or only its part is written to a temporary file. By default, buffer size is equal to two memory pages. This is 8K on x86, other 32-bit platforms, and x86-64. It is usually 16K on other 64-bit platforms. 定義了Nginx接收HTTP包體的內(nèi)存緩沖區(qū)大小。也就是說,HTTP包體會先接收到指定的這塊緩存中,之后才決定是否寫入磁盤。注意 如果用戶請求中含有HTTP頭部Content-Length,并且其標識的長度小于定義的buffer大小,那么Nginx會自動降低本次請求所使用的內(nèi)存buffer,以降低內(nèi)存消耗。 ngx_http_core_module
proxy buffer
名稱 默認配置 作用域 官方說明 中文解讀 模塊
proxy_buffering proxy_buffering on; http, server, location Enables or disables buffering of responses from the proxied server. 是否開啟對后端response的緩沖 ngx_http_proxy_module
proxy_connect_timeout proxy_connect_timeout 60s; http, server, location Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds. 指定一個連接到代理服務(wù)器的超時時間,單位為秒,需要注意的是這個時間最好不要超過75秒。 ngx_http_proxy_module
proxy_read_timeout proxy_read_timeout 60s; http, server, location Defines a timeout for reading a response from the proxied server. The timeout is set only between two successive read operations, not for the transmission of the whole response. If the proxied server does not transmit anything within this time, the connection is closed. 決定讀取后端服務(wù)器應(yīng)答的超時時間,單位為秒,它決定nginx將等待多久時間來取得一個請求的應(yīng)答。超時時間是指兩次連續(xù)讀操作之間的超時時間。某些情況下代理服務(wù)器將花很長的時間來獲得頁面應(yīng)答(例如如當接收一個需要很多計算的報表時),可以在不同的location里面設(shè)置不同的值。 ngx_http_proxy_module
proxy_send_timeout proxy_send_timeout 60s; http, server, location Sets a timeout for transmitting a request to the proxied server. The timeout is set only between two successive write operations, not for the transmission of the whole request. If the proxied server does not receive anything within this time, the connection is closed. 設(shè)置代理服務(wù)器轉(zhuǎn)發(fā)請求的超時時間,單位為秒,超時時間為兩次連續(xù)寫操作之間的超時時間,如果超過這個時間代理服務(wù)器沒有數(shù)據(jù)轉(zhuǎn)發(fā)到被代理服務(wù)器,nginx將關(guān)閉連接 ngx_http_proxy_module
proxy_buffer_size proxy_buffer_size 4k或8k; http, server, location Sets the size of the buffer used for reading the first part of the response received from the proxied server. This part usually contains a small response header. By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform. It can be made smaller, however. 緩存response的第一部分,通常是header,默認proxy_buffer_size 被設(shè)置成 proxy_buffers 里一個buffer 的大小,當然可以設(shè)置更小些。 ngx_http_proxy_module
proxy_buffers proxy_buffers 8 4k或8k; http, server, location Sets the number and size of the buffers used for reading a response from the proxied server, for a single connection. By default, the buffer size is equal to one memory page. This is either 4K or 8K, depending on a platform. 前面一個是num,后面一個是每個buffer的size.Nginx將會盡可能的讀取后端服務(wù)器的數(shù)據(jù)到buffer,直到proxy_buffers設(shè)置的所有buffer們被寫滿或者數(shù)據(jù)被讀取完(EOF),此時Nginx開始向客戶端傳輸數(shù)據(jù),會同時傳輸這一整串buffer們。如果數(shù)據(jù)很大的話,Nginx會接收并把他們寫入到temp_file里去,大小由proxy_max_temp_file_size 控制。 ngx_http_proxy_module
proxy_max_temp_file_size proxy_max_temp_file_size 1024m; http, server, location When buffering of responses from the proxied server is enabled, and the whole response does not fit into the buffers set by the proxy_buffer_size and proxy_buffers directives, a part of the response can be saved to a temporary file. This directive sets the maximum size of the temporary file. The size of data written to the temporary file at a time is set by the proxy_temp_file_write_size directive.The zero value disables buffering of responses to temporary files. 默認情況下proxy_max_temp_file_size值為1024MB,也就是說后端服務(wù)器的文件不大于1G都可以緩存到nginx代理硬盤中,如果超過1G,那么文件不緩存,而是直接中轉(zhuǎn)發(fā)送給客戶端.如果proxy_max_temp_file_size設(shè)置為0,表示不使用臨時緩存。 ngx_http_proxy_module
proxy_busy_buffers_size proxy_busy_buffers_size 8k或16k; http, server, location When buffering of responses from the proxied server is enabled, limits the total size of buffers that can be busy sending a response to the client while the response is not yet fully read. In the meantime, the rest of the buffers can be used for reading the response and, if needed, buffering part of the response to a temporary file. By default, size is limited by the size of two buffers set by the proxy_buffer_size and proxy_buffers directives. 一旦proxy_buffers設(shè)置的buffer被寫入,直到buffer里面的數(shù)據(jù)被完整的傳輸完(傳輸?shù)娇蛻舳耍@個buffer將會一直處 在busy狀態(tài),我們不能對這個buffer進行任何別的操作。所有處在busy狀態(tài)的buffer size加起來不能超過proxy_busy_buffers_size,所以proxy_busy_buffers_size是用來控制同時傳輸?shù)娇蛻舳说腷uffer數(shù)量的。 ngx_http_proxy_module
proxy_temp_file_write_size proxy_temp_file_write_size 8k或16k; http, server, location Limits the size of data written to a temporary file at a time, when buffering of responses from the proxied server to temporary files is enabled. By default, size is limited by two buffers set by the proxy_buffer_size and proxy_buffers directives. The maximum size of a temporary file is set by the proxy_max_temp_file_size directive. 指定每次寫temp file的大小 ngx_http_proxy_module
proxy_temp_path proxy_temp_path proxy_temp; http, server, location Defines a directory for storing temporary files with data received from proxied servers. Up to three-level subdirectory hierarchy can be used underneath the specified directory. For example, in the following configuration 指定緩沖代理服務(wù)器response的臨時文件夾 ngx_http_proxy_module
實例
http {
    include       mime.types;
    default_type  application/octet-stream;

    access_log  /dev/stdout main;

    ##------socket配置----------##
    sendfile        on;
    tcp_nodelay     on;
    #tcp_nopush     on;
    #server_names_hash_max_size 1024; ##設(shè)置servers hash表的大小,默認512;如果配置了多個虛擬server,比如24個域名對應(yīng)一個地址,則需要考慮改此參數(shù)


    ##------client端請求設(shè)置----------##
    keepalive_timeout  65;
    client_header_timeout  60; ##讀取整個header的超時時間
    client_body_timeout    60; ##連續(xù)兩次讀取body的超時時間
    send_timeout           10; ##這個超時時間是發(fā)送響應(yīng)的超時時間,即Nginx服務(wù)器向客戶端發(fā)送了數(shù)據(jù)包,但客戶端一直沒有去接收這個數(shù)據(jù)包。如果某個連接超過send_timeout定義的超時時間,那么Nginx將會關(guān)閉這個連接。timeout between two successive write operations for a client receiving a response.

    client_header_buffer_size    128k; ##太小了會報400,?Request Header Or Cookie Too Large,默認1kb. 定義了正常情況下Nginx接收用戶請求中HTTP header部分(包括HTTP行和HTTP頭部)時分配的內(nèi)存buffer大小。有時,請求中的HTTP header部分可能會超過這個大小,這時large_client_header_buffers定義的buffer將會生效。
    large_client_header_buffers  4 128k; ##定義了Nginx接收一個超大HTTP頭部請求的buffer個數(shù)和每個buffer的大小。如果HTTP請求行(如GET/index HTTP/1.1)的大小超過單個buffer,則返回"Request URI too large"(414)。請求中一般會有許多header,每一個header的大小也不能超過單個buffer的大小,否則會返回"Bad request"(400)。當然,請求行和請求頭部的總和也不可以超過buffer個數(shù)*buffer大小。
    client_max_body_size           20m; ## 客戶端請求body的最大大小,超過則報413 Request Entity Too Large,通常用來設(shè)置文件上傳大小
    ## client_body_temp_path      client_body_temp; ##默認是/usr/local/openresty/nginx/client_body_temp,可以自定義支持多級目錄,client_body_temp_path  client_body_temp 1 2;
    client_body_buffer_size      128k;  ##在接收HTTP包體時,如果包體的大小大于client_body_buffer_size,則會以一個遞增的整數(shù)命名并存放到client_body_temp_path指定的目錄中


    ##-------proxy后端的設(shè)置---------##
    proxy_buffering on; #默認是on
    proxy_connect_timeout    10; ##控制連接超時,如果連接不上,直接502,Connection refused
    proxy_read_timeout       60; ##控制連續(xù)兩次讀取后端響應(yīng)的超時,如果后端長時間未響應(yīng)則504,Connection timed out
    proxy_send_timeout       10; ##控制連續(xù)兩次向后端發(fā)送請求的超時,一般比較少發(fā)生
    proxy_buffer_size        128k; ##緩存response的第一部分,通常是header,默認proxy_buffer_size 被設(shè)置成 proxy_buffers 里一個buffer 的大小,當然可以設(shè)置更小些。
    proxy_buffers 128 128k; ##前面一個是num,后面一個是一個buffer的size,因此總共的buffers大小為=128*128k.Nginx將會盡可能的讀取后端服務(wù)器的數(shù)據(jù)到buffer,直到proxy_buffers設(shè)置的所有buffer們被寫滿或者數(shù)據(jù)被讀取完(EOF),此時Nginx開始向客戶端傳輸數(shù)據(jù),會同時傳輸這一整串buffer們。如果數(shù)據(jù)很大的話,Nginx會接收并把他們寫入到temp_file里去,大小由proxy_max_temp_file_size 控制。
    proxy_max_temp_file_size 1024m; ##默認情況下proxy_max_temp_file_size值為1024MB,也就是說后端服務(wù)器的文件不大于1G都可以緩存到nginx代理硬盤中,如果超過1G,那么文件不緩存,而是直接中轉(zhuǎn)發(fā)送給客戶端.如果proxy_max_temp_file_size設(shè)置為0,表示不使用臨時緩存。
    proxy_busy_buffers_size 128k; ##一旦proxy_buffers設(shè)置的buffer被寫入,直到buffer里面的數(shù)據(jù)被完整的傳輸完(傳輸?shù)娇蛻舳耍@個buffer將會一直處 在busy狀態(tài),我們不能對這個buffer進行任何別的操作。所有處在busy狀態(tài)的buffer size加起來不能超過proxy_busy_buffers_size,所以proxy_busy_buffers_size是用來控制同時傳輸?shù)娇蛻舳说腷uffer數(shù)量的。
    proxy_temp_file_write_size 128k; ##指定每次寫temp file的大小
    proxy_temp_path proxy_temp; ##默認值為/usr/local/openresty/nginx/proxy_temp

    //......
}
doc

ngx_http_core_module

ngx_http_proxy_module

內(nèi)存及磁盤資源的分配

nginx proxy_buffers相關(guān)配置解釋

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://specialneedsforspecialkids.com/yun/39757.html

相關(guān)文章

  • nginx lua api解讀

    摘要:對于需要進一步注意的是參數(shù)的使用,可以傳入所定義的所有的狀態(tài)碼常量如等和兩個模塊內(nèi)核常量只支持和這兩個,如果傳入其他的如等則進程住。 序 本文主要解讀下nginx lua module的主要方法和api。 ngx_lua運行階段 showImg(https://segmentfault.com/img/bVHFqI?w=1005&h=910); initialization phase...

    shery 評論0 收藏0
  • nginx gzip配置參數(shù)解讀

    序 本文主要解析一下nginx ngx_http_gzip_module以及ngx_http_gzip_static_module中的gzip相關(guān)配置參數(shù)。 gzip 名稱 默認配置 作用域 官方說明 中文解讀 模塊 gzip gzip off; http, server, location, if in location Enables or disables gzipping of ...

    付永剛 評論0 收藏0
  • nginx limit配置參數(shù)解讀

    序 本文主要解析一下ngx_http_core_module、ngx_http_limit_conn_module以及ngx_http_limit_req_module中的limit相關(guān)配置參數(shù)。 limit_rate 名稱 默認配置 作用域 官方說明 中文解讀 模塊 limit_rate limit_rate 0; http, server, location, if in locat...

    Jonathan Shieber 評論0 收藏0
  • nginx proxy cache配置參數(shù)解讀

    序 本文主要解析一下nginx ngx_http_proxy_module中的cache相關(guān)配置參數(shù)。 proxy_cache 名稱 默認配置 作用域 官方說明 中文解讀 模塊 proxy_cache proxy_cache off; http, server, location Defines a shared memory zone used for caching. The sam...

    alanoddsoff 評論0 收藏0
  • nginx rewrite配置解讀

    序 本文主要解析一下ngx_http_rewrite_module中的rewrite相關(guān)配置。 directives 名稱 默認配置 作用域 官方說明 中文解讀 模塊 break 無 server, location, if Stops processing the current set of ngx_http_rewrite_module directives. 中斷當前的重寫 ng...

    IamDLY 評論0 收藏0

發(fā)表評論

0條評論

pf_miles

|高級講師

TA的文章

閱讀更多
最新活動
閱讀需要支付1元查看
<