詳解nginx模塊使用方法-創(chuàng)新互聯(lián)

詳解nginx模塊使用方法

  1. 與套接字相關(guān)的配置

    創(chuàng)新互聯(lián)公司:于2013年開始為各行業(yè)開拓出企業(yè)自己的“網(wǎng)站建設(shè)”服務(wù),為上1000家公司企業(yè)提供了專業(yè)的成都網(wǎng)站制作、做網(wǎng)站、網(wǎng)頁設(shè)計和網(wǎng)站推廣服務(wù), 按需求定制網(wǎng)站由設(shè)計師親自精心設(shè)計,設(shè)計的效果完全按照客戶的要求,并適當(dāng)?shù)奶岢龊侠淼慕ㄗh,擁有的視覺效果,策劃師分析客戶的同行競爭對手,根據(jù)客戶的實際情況給出合理的網(wǎng)站構(gòu)架,制作客戶同行業(yè)具有領(lǐng)先地位的。
    (1)server { ... }
        配置一個虛擬主機;
        server {
              listen address[:PORT]|PORT;
               server_name SERVER_NAME;
               root /PATH/TO/DOCUMENT_ROOT;                            
               }
    (2)listen PORT|address[:port]|unix:/PATH/TO/SOCKET_FILE
        listen address[:port] [default_server] [ssl] [http2 | spdy]  [backlog=number] [rcvbuf=size] [sndbuf=size]
        default_server:設(shè)定為默認虛擬主機;
         ssl:限制僅能夠通過ssl連接提供服務(wù);
         backlog=number:后援隊列長度;
         rcvbuf=size:接收緩沖區(qū)大?。?     sndbuf=size:發(fā)送緩沖區(qū)大小
    (3)server_name name ...;
    指明虛擬主機的主機名稱;后可跟多個由空白字符分隔的字符串;
    支持*通配任意長度的任意字符;server_name *.magedu.com  www.magedu.*
    支持~起始的字符做正則表達式模式匹配;server_name ~^www\d+\.magedu\.com$
    匹配機制:
            (a) 首先是字符串精確匹配;
            (b) 左側(cè)*通配符;
            (c) 右側(cè)*通配符;
            (d) 正則表達式;
    (4)tcp_nodelay on | off;
       在keepalived模式下的連接是否啟用TCP_NODELAY選項;表示在長連接模式下一個個發(fā)包,不打包一起發(fā)
        tcp_nopush on|off;
        在sendfile模式下,是否啟用TCP_CORK選項;表示等于用戶空間把http首部送過來一起發(fā)
    (5)sendfile on | off;
       是否啟用sendfile功能;表示把響應(yīng)報文首部和文件開頭放在一個報文發(fā)送,在一個報文發(fā)送文件

    2.定義路徑相關(guān)的配置:

    (1)root path;
    設(shè)置web資源路徑映射;用于指明用戶請求的url所對應(yīng)的本地文件系統(tǒng)上的文檔所在目錄路徑;可用的位置:http, server, location, if in location;
    (2)location [ = | ~ | ~* | ^~ ] uri { ... }
      在一個server中l(wèi)ocation配置段可存在多個,用于實現(xiàn)從uri到文件系統(tǒng)的路徑映射;ngnix會根據(jù)用戶請求的URI來檢查定義的所有l(wèi)ocation,并找出一個最佳匹配,而后應(yīng)用其配置;
                 =:對URI做精確匹配;
                            location  =  / {
                                ...
                            }
                     ~:對URI做正則表達式模式匹配,區(qū)分字符大小寫; 
                     ~*:對URI做正則表達式模式匹配,不區(qū)分字符大小寫;
                     ^~:對URI的左半部分做匹配檢查,不區(qū)分字符大小寫;
                     不帶符號:匹配起始于此uri的所有的url;
                     匹配優(yōu)先級:=, ^~, ~/~*,不帶符號;
                      root /vhosts/www/htdocs/
                  http://www.www.com/index.html --> /vhosts/www/htdocs/index.html
                        server {
                            root  /vhosts/www/htdocs/
    
                            location /admin/ {
                                root /webapps/app1/data/
                            }
                        }
    (3)、alias path;
    定義路徑別名,文檔映射的另一種機制;僅能用于location上下文;
    注意:location中使用root指令和alias指令的意義不同;
             (a) root,給定的路徑對應(yīng)于location中的/uri/左側(cè)的/;
            (b) alias,給定的路徑對應(yīng)于location中的/uri/右側(cè)的/
    (4)index file ...;
     默認資源;http, server, location;
    (5)error_page code ... [=[response]] uri;
    Defines the URI that will be shown for the specified errors.

    3.定義客戶端請求的相關(guān)配置:

    (1)keepalive_timeout timeout [header_timeout];(負載均衡短,后端服務(wù)器長)
       設(shè)定保持連接的超時時長,0表示禁止長連接;默認為75s;
    (2)keepalive_requests number;
        在一次長連接上所允許請求的資源的大數(shù)量,默認為100;
    (3)、keepalive_disable none | browser ...;
       對哪種瀏覽器禁用長連接;
    (4)send_timeout time;
        向客戶端發(fā)送響應(yīng)報文的超時時長,此處,是指兩次寫操作之間的間隔時長;
    (5)client_body_buffer_size size;(post上傳大文件時)
        用于接收客戶端請求報文的body部分的緩沖區(qū)大??;默認為16k;超出此大小時,其將被暫存到磁盤上的由                  client_body_temp_path指令所定義的位置;
    (6)client_body_temp_path path [level1 [level2 [level3]]];
      設(shè)定用于存儲客戶端請求報文的body部分的臨時存儲路徑及子目錄結(jié)構(gòu)和數(shù)量;

    4.對客戶端進行限制的相關(guān)配置:

    (1)limit_rate rate;
    限制響應(yīng)給客戶端的傳輸速率,單位是bytes/second,0表示無限制;
    (2)limit_except method ... { ... }
    限制對指定的請求方法之外的其它方法的使用客戶端;
    limit_except GET {
        allow 192.168.1.0/24;
        deny  all;
    }

    5.文件操作優(yōu)化的配置:

    (1)aio on | off | threads[=pool];
    是否啟用aio功能;
    (2)directio size | off;
    在Linux主機啟用O_DIRECT標(biāo)記,此處意味文件大于等于給定的大小時使用,例如directio 4m;
    (3)open_file_cache off;(緩存元數(shù)據(jù))
    open_file_cache max=N [inactive=time];
        nginx可以緩存以下三種信息:
            (a) 文件的描述符、文件大小和最近一次的修改時間;
            (b) 打開的目錄結(jié)構(gòu);
            (c) 沒有找到的或者沒有權(quán)限訪問的文件的相關(guān)信息;
        max=N:可緩存的緩存項上限;達到上限后會使用LRU算法(最近最少使用)實現(xiàn)緩存管理;
        inactive=time:緩存項的非活動時長,在此處指定的時長內(nèi)未被命中的或命中的次數(shù)少于open_file_cache_min_uses指令所指定的次數(shù)的緩存項即為非活動項;
    (4)open_file_cache_valid time;
    緩存項有效性的檢查頻率;默認為60s;
    (5)open_file_cache_min_uses number;
    在open_file_cache指令的inactive參數(shù)指定的時長內(nèi),至少應(yīng)該被命中多少次方可被歸類為活動項;
    (6)open_file_cache_errors on | off;
       是否緩存查找時發(fā)生錯誤的文件一類的信息;

    6.ngx_http_access_module模塊:
    實現(xiàn)基于ip的訪問控制功能

    (1)allow address | CIDR | unix: | all;
    (2)deny address | CIDR | unix: | all;

    7.ngx_http_auth_basic_module模塊:

    (1)auth_basic string | off;
    (2)auth_basic_user_file file;
    location /admin/ {
        alias /webapps/app1/data/;
        auth_basic "Admin Area";
        auth_basic_user_file /etc/nginx/.ngxpasswd;
    }
    
    注意:htpasswd命令由httpd-tools所提供;

    8.ngx_http_stub_status_module模塊:
    用于輸出nginx的基本狀態(tài)信息;

    Active connections: 291
    server accepts handled requests
        16630948 16630948 31070465
    Reading: 6 Writing: 179 Waiting: 106     
    Active connections: 活動狀態(tài)的連接數(shù);
    accepts:已經(jīng)接受的客戶端請求的總數(shù);
    handled:已經(jīng)處理完成的客戶端請求的總數(shù);
    requests:客戶端發(fā)來的總的請求數(shù);
    Reading:處于讀取客戶端請求報文首部的連接的連接數(shù);
    Writing:處于向客戶端發(fā)送響應(yīng)報文過程中的連接數(shù);
    Waiting:處于等待客戶端發(fā)出請求的空閑連接數(shù);
    stub_status;
    配置示例:
        location  /basic_status {
            stub_status;
        }

    9.ngx_http_log_module模塊

    (1)log_format name string ...;
    string可以使用nginx核心模塊及其它模塊內(nèi)嵌的變量;
    (2)access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]];
    access_log off;
    
    訪問日志文件路徑,格式及相關(guān)的緩沖的配置;
        buffer=size
        flush=time
    (3)open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];
    open_log_file_cache off;
        緩存各日志文件相關(guān)的元數(shù)據(jù)信息;
    
        max:緩存的大文件描述符數(shù)量;
        min_uses:在inactive指定的時長內(nèi)訪問大于等于此值方可被當(dāng)作活動項;
        inactive:非活動時長;
        valid:驗正緩存中各緩存項是否為活動項的時間間隔;

    10.ngx_http_gzip_module:

    (1)gzip on | off;
    Enables or disables gzipping of responses.
    (2)gzip_comp_level level;
    Sets a gzip compression level of a response. Acceptable values are in the range from 1 to 9.
    (3)gzip_disable regex ...;
    Disables gzipping of responses for requests with “User-Agent” header fields matching any of the specified regular expressions.
    (4)gzip_min_length length;
    啟用壓縮功能的響應(yīng)報文大小閾值;
    (5)gzip_buffers number size;
    支持實現(xiàn)壓縮功能時為其配置的緩沖區(qū)數(shù)量及每個緩存區(qū)的大??;
    (6)gzip_proxied off | expired | no-cache | no-store | private | no_last_modified | no_etag | auth | any ...;
    nginx作為代理服務(wù)器接收到從被代理服務(wù)器發(fā)送的響應(yīng)報文后,在何種條件下啟用壓縮功能的;
        off:對代理的請求不啟用
        no-cache, no-store,private:表示從被代理服務(wù)器收到的響應(yīng)報文首部的Cache-Control的值為此三者中任何一個,則啟用壓縮功能;
    (7)gzip_types mime-type ...;
    壓縮過濾器,僅對此處設(shè)定的MIME類型的內(nèi)容啟用壓縮功能;
        示例:
    gzip  on;
    gzip_comp_level 6;
    gzip_min_length 64;
    gzip_proxied any;
    gzip_types text/xml text/css  application/javascript;

    8.ngx_http_ssl_module模塊:

    (1) ssl on | off;
    Enables the HTTPS protocol for the given virtual server.
    (2)ssl_certificate file;
    當(dāng)前虛擬主機使用PEM格式的證書文件;
    (3)ssl_certificate_key file;
    當(dāng)前虛擬主機上與其證書匹配的私鑰文件;
    (4)ssl_protocols [SSLv2] [SSLv3] [TLSv1] [TLSv1.1] [TLSv1.2];
    支持ssl協(xié)議版本,默認為后三個;
    (5)、ssl_session_cache off | none | [builtin[:size]] [shared:name:size];
    builtin[:size]:使用OpenSSL內(nèi)建的緩存,此緩存為每worker進程私有;
     [shared:name:size]:在各worker之間使用一個共享的緩存;
    (6)ssl_session_timeout time;
    客戶端一側(cè)的連接可以復(fù)用ssl session cache中緩存 的ssl參數(shù)的有效時長;
        配置示例:
    server {
        listen 443 ssl;
        server_name www.magedu.com;
        root /vhosts/ssl/htdocs;
        ssl on;
        ssl_certificate /etc/nginx/ssl/nginx.crt;
        ssl_certificate_key /etc/nginx/ssl/nginx.key;
        ssl_session_cache shared:sslcache:20m;
    }

    9.ngx_http_rewrite_module模塊:

    (1)rewrite regex replacement [flag]
    將用戶請求的URI基于regex所描述的模式進行檢查,匹配到時將其替換為replacement指定的新的URI;
    注意:如果在同一級配置塊中存在多個rewrite規(guī)則,那么會自下而下逐個檢查;被某條件規(guī)則替換完成后,會重新一輪的替換檢查,因此,隱含有循環(huán)機制;[flag]所表示的標(biāo)志位用于控制此循環(huán)機制;
         last:重寫完成后停止對當(dāng)前URI在當(dāng)前l(fā)ocation中后續(xù)的其它重寫操作,而后對新的URI啟動新一輪重寫檢查;提前重啟新一輪循環(huán);
    break:重寫完成后停止對當(dāng)前URI在當(dāng)前l(fā)ocation中后續(xù)的其它重寫操作,而后直接跳轉(zhuǎn)至重寫規(guī)則配置塊之后的其它配置;結(jié)束循環(huán);
    redirect:重寫完成后以臨時重定向方式直接返回重寫后生成的新URI給客戶端,由客戶端重新發(fā)起請求;不能以http://或https://開頭;(301)
    permanent:重寫完成后以永久重定向方式直接返回重寫后生成的新URI給客戶端,由客戶端重新發(fā)起請求;(302)
    (2)return
    return code [text];
    return code URL;
    return URL;
    Stops processing and returns the specified code to a client.
    (3)rewrite_log on | off;
     是否開啟重寫日志;
    (4) if (condition) { ... }
    引入一個新的配置上下文 ;條件滿足時,執(zhí)行配置塊中的配置指令;server, location:  
    condition:
        比較操作符:
            ==
            !=
            ~:模式匹配,區(qū)分字符大小寫;
            ~*:模式匹配,不區(qū)分字符大小寫;
            !~:模式不匹配,區(qū)分字符大小寫;
            !~*:模式不匹配,不區(qū)分字符大小寫;
        文件及目錄存在性判斷:
            -e, !-e
            -f, !-f
            -d, !-d
            -x, !-x

    10.ngx_http_referer_module模塊

    (1)valid_referers none | blocked | server_names | string ...;
    定義referer首部的合法可用值;
        none:請求報文首部沒有referer首部;
        blocked:請求報文的referer首部沒有值;
        server_names:參數(shù),其可以有值作為主機名或主機名模式;
            arbitrary_string:直接字符串,但可使用*作通配符;
            regular expression:被指定的正則表達式模式匹配到的字符串;要使用~打頭,例如 ~.*\.magedu\.com;            
    配置示例:
        valid_referers none block server_names *.magedungx_http_proxy_module模塊:.com *.mageedu.com magedu.* mageedu.* ~\.magedu\.;
        if($invalid_referer) {
            return http://www.magedu.com/invalid.jpg;
        }
        if($invalid_referer) {
            return 403;
        }

11.ngx_http_proxy_module模塊:

   (1)proxy_pass URL;
         Context:    location, if in location, limit_except
         注意:proxy_pass后面的路徑不帶uri時,其會將location的uri傳遞給后端主機            server {
                   ...
                  server_name HOSTNAME;
                  location /uri/ {
                  proxy http://host[:port];
                  }
                 ...
           }
         http://HOSTNAME/uri --> http://host/uri
             proxy_pass后面的路徑是一個uri時,其會將location的uri替換為proxy_pass的uri;
              server {
                    ...
                   server_name HOSTNAME;
                   location /uri/ {
                   proxy http://host/new_uri/;
                   }
                 ..
              }
         http://HOSTNAME/uri/ --> http://host/new_uri/
           如果location定義其uri時使用了正則表達式的模式,或在if語句或limt_execept中使用proxy_pass指令,則                    proxy_pass之后必須不能使用uri; 用戶請求時傳遞的uri將直接附加代理到的服務(wù)的之后;
              server {
                ...
               server_name HOSTNAME;
               location ~|~* /uri/ {
               proxy http://host;
               }
               ...
             }
(2)proxy_set_header field value;
                設(shè)定發(fā)往后端主機的請求報文的請求首部的值;Context:    http, server, location
                proxy_set_header X-Real-IP  $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
(3)proxy_cache_path
                定義可用于proxy功能的緩存;Context:    http            
                proxy_cache_path path [levels=levels] [use_temp_path=on|off] keys_zone=name:size                       [inactive=time] [max_size=size] [manager_files=number] [manager_sleep=time] [manager_threshold=time] [loader_files=number] [loader_sleep=time] [loader_threshold=time] [purger=on|off] [purger_files=number] [purger_sleep=time] [purger_threshold=time];
(4)proxy_cache zone | off;
                 指明要調(diào)用的緩存,或關(guān)閉緩存機制;Context:    http, server, location
(5)proxy_cache_key string;
                   緩存中用于“鍵”的內(nèi)容;
                   默認值:proxy_cache_key $scheme$proxy_host$request_uri;
(6)proxy_cache_valid [code ...] time;
                 定義對特定響應(yīng)碼的響應(yīng)內(nèi)容的緩存時長;
                 定義在http{...}中;

proxy_cache_path /var/cache/nginx/proxy_cache levels=1:1:1 keys_zone=pxycache:20m max_size=1g;
                 定義在需要調(diào)用緩存功能的配置段,例如server{...};
                 proxy_cache pxycache;
                 proxy_cache_key $request_uri;
                 proxy_cache_valid 200 302 301 1h;
                 proxy_cache_valid any 1m;
                 proxy_cache_use_stale http_502;
(7)proxy_cache_use_stale(后端服務(wù)器出現(xiàn)了問題,反向代理用緩存來響應(yīng))
                   proxy_cache_use_stale error | timeout | invalid_header | updating | http_500 | http_502 | http_503 | http_504 | http_403 | http_404 | off ...;
                   Determines in which cases a stale cached response can be used when an error occurs during communication with the proxied server.
(8)proxy_cache_methods GET | HEAD | POST ...;
               If the client request method is listed in this directive then the response will be cached. “GET” and “HEAD” methods are always added to the list, though it is recommended to specify them explicitly.
(9)proxy_hide_header field;
               By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed.
(10)proxy_connect_timeout time;
              Defines a timeout for establishing a connection with a proxied server. It should be noted that this timeout cannot usually exceed 75 seconds.
              默認為60s;最長為75s;
(11)proxy_read_timeout time;
             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.
(12)proxy_send_timeout time;
               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.

12.ngx_http_headers_module模塊:
向由代理服務(wù)器響應(yīng)給客戶端的響應(yīng)報文添加自定義首部,或修改指定首部的值;

 (1)add_header name value [always]
             添加自定義首部;
             add_header X-Via  $server_addr;
             add_header X-Accel $server_name;
       (2)expires [modified] time;
            expires epoch | max | off;
           用于定義Expire或Cache-Control首部的值;

13.ngx_http_fastcgi_module模塊:

(1)fastcgi_pass address;
            address為fastcgi server的地址;    location, if in location;
             http://www.ilinux.io/admin/index.php --> /admin/index.php (uri)
             /data/application/admin/index.php
(2)fastcgi_index name;
             fastcgi默認的主頁資源;
 (3)fastcgi_param parameter value [if_not_empty];
            Sets a parameter that should be passed to the FastCGI server. The value can contain text, variables, and their combination.
       配置示例1:
        前提:配置好fpm server和mariadb-server服務(wù);
        location ~* \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
      配置示例2:通過/pm_status和/ping來獲取fpm server狀態(tài)信息;
         location ~* ^/(pm_status|ping)$ {
        include        fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param  SCRIPT_FILENAME  $fastcgi_script_name;
    }     
   (4)fastcgi_cache_path path [levels=levels] [use_temp_path=on|off] keys_zone=name:size  [inactive=time] [max_size=size] [manager_files=number] [manager_sleep=time] [manager_threshold=time] [loader_files=number] [loader_sleep=time] [loader_threshold=time] [purger=on|off] [purger_files=number]             
          [purger_sleep=time] [purger_threshold=time];      
          定義fastcgi的緩存;緩存位置為磁盤上的文件系統(tǒng),由path所指定路徑來定義;
          levels=levels:緩存目錄的層級數(shù)量,以及每一級的目錄數(shù)量;levels=ONE:TWO:THREE
          leves=1:2:2
         keys_zone=name:size
         k/v映射的內(nèi)存空間的名稱及大小
          inactive=time
         非活動時長
          max_size=size
          磁盤上用于緩存數(shù)據(jù)的緩存空間上限
   (5)fastcgi_cache zone | off;
         調(diào)用指定的緩存空間來緩存數(shù)據(jù);http, server, location
   (6)fastcgi_cache_key string;
       定義用作緩存項的key的字符串;
    (7)fastcgi_cache_methods GET | HEAD | POST ...;
       為哪些請求方法使用緩存;
   (8)fastcgi_cache_min_uses number;
        緩存空間中的緩存項在inactive定義的非活動時間內(nèi)至少要被訪問到此處所指定的次數(shù)方可被認作活動項;
   (9)fastcgi_cache_valid [code ...] time;
        不同的響應(yīng)碼各自的緩存時長;
         示例:
    http {
        ...
        fastcgi_cache_path /var/cache/nginx/fastcgi_cache levels=1:2:1 keys_zone=fcgi:20m inactive=120s;
        ...
        server {
            ...
            location ~* \.php$ {
                ...
                fastcgi_cache fcgi;
                fastcgi_cache_key $request_uri;
                fastcgi_cache_valid 200 302 10m;
                fastcgi_cache_valid 301 1h;
                fastcgi_cache_valid any 1m;    
                ...
            }
            ...
        }
        ...
    }
  (10)fastcgi_keep_conn on | off;(發(fā)請求時)
         By default, a FastCGI server will close a connection right after sending the response. However, when this directive is set to the value on, nginx will instruct a FastCGI server to keep connections open.

14.ngx_http_upstream_module模塊

(1)upstream name { ... }
         定義后端服務(wù)器組,會引入一個新的上下文;Context: http
         upstream httpdsrvs {
        server ...
        server...
        ...
    }
  (2)server address [parameters];
       在upstream上下文中server成員,以及相關(guān)的參數(shù);Context:    upstream
       address的表示格式:
           unix:/PATH/TO/SOME_SOCK_FILE
           IP[:PORT]
           HOSTNAME[:PORT]
      parameters:
           weight=number
            權(quán)重,默認為1;
    max_fails=number
        失敗嘗試大次數(shù);超出此處指定的次數(shù)時,server將被標(biāo)記為不可用;
    fail_timeout=time
        設(shè)置將服務(wù)器標(biāo)記為不可用狀態(tài)的超時時長;
    max_conns
        當(dāng)前的服務(wù)器的大并發(fā)連接數(shù);
    backup
        將服務(wù)器標(biāo)記為“備用”,即所有服務(wù)器均不可用時此服務(wù)器才啟用;
    down
        標(biāo)記為“不可用”;
(3)least_conn;
    最少連接調(diào)度算法,當(dāng)server擁有不同的權(quán)重時其為wlc;
(4)ip_hash;
      源地址hash調(diào)度方法;
(5)hash key [consistent];
      基于指定的key的hash表來實現(xiàn)對請求的調(diào)度,此處的key可以直接文本、變量或二者的組合;
      作用:將請求分類,同一類請求將發(fā)往同一個upstream server;
      If the consistent parameter is specified the ketama consistent hashing method will be used instead.
      示例:
        hash $request_uri consistent;(提高命中率)
        hash $remote_addr;
(6)keepalive connections;
       為每個worker進程保留的空閑的長連接數(shù)量;每worker與后端服務(wù)保持的大空閑長連接數(shù)量

15.ngx_stream_core_module模塊:

(1)proxy_pass address;
(2)proxy_timeout timeout:默認為10s,連接建立起來了,請求發(fā)出去的超時時間
(3)proxy_connect_timeout time:設(shè)置nginx與被代理的服務(wù)器嘗試建立連接的超時時長;默認為60s;
示例:stream { ... }
    定義stream相關(guān)的服務(wù);Context:main
        stream {
        upstream sshsrvs {
            server 192.168.22.2:22;
            server 192.168.22.3:22;
            least_conn;
        }
        server {
            listen 10.1.0.6:22022;
            proxy_pass sshsrvs;
        }
    }    

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機、免備案服務(wù)器”等云主機租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。

分享題目:詳解nginx模塊使用方法-創(chuàng)新互聯(lián)
標(biāo)題URL:http://muchs.cn/article10/djjsgo.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站關(guān)鍵詞優(yōu)化、域名注冊、外貿(mào)建站微信小程序、軟件開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

小程序開發(fā)