1. 程式人生 > >nginx反向代理--upstream模組

nginx反向代理--upstream模組

1.nginx負載均衡依賴於ngx_http_upstream_module模組,支援以下代理模式:

proxy_pass:一般用於反向代理

fastcgi_pass:一般用於和動態檔案互動,php等

memcached_pass:

2.upstream模組編寫

upsrtream 模組名{

     server abc.example.com weight=5;

     可以接域名或ip,如果不加埠號預設是80,weight是權重,數值越大權重越高

     server abc.com:8080;

     server unix:/tmp/backend3;

     指定socket檔案

}

3.upstream模組相關說明

1)應該放在配置檔案http標籤內

2)upstream預設演算法是wrr(加權輪詢)

3)內容相關引數

max_fails最大嘗試次數,連線後面realserver次數

backup熱備配置,當啟用的realserver都失敗後啟用backup

fail_timeout失敗超時時間,配合上面max_fails,檢查n次後,等待n秒

down伺服器不可用,配合ip_hash使用