1. 程式人生 > >windows平臺下利用Nginx做負載均衡

windows平臺下利用Nginx做負載均衡

htm oot 部署 top proxy rec cnblogs access cast

1.下載nginx(http://nginx.org/en/download.html)安裝包,解壓,並使用cmd命令轉到nginx.exe所在的目錄

2.執行cmd命令start nginx啟動nginx服務

3.在iis上部署3個站點(數量任意),ip地址分別為:

192.168.199.104:8081
192.168.199.104:8082
192.168.199.104:8083

4.配置nginx.conf

    #服務器的集群
    upstream  netitcast.com {  #服務器集群名字
          #server   172.16.21.13:8081 weight=1;#服務器配置   weight是權重的意思,權重越大,分配的概率越大。
        #server   
192.168.1.186:8081 weight=1; server 172.16.1.14:8081 weight=2; server 172.16.1.15:8081 weight=1; #server 172.16.1.15:80 weight=1; } #當前的Nginx的配置 server { listen 80;#監聽80端口,可以改成其他端口 server_name localhost;############## 當前服務的域名 #charset koi8
-r; #access_log logs/host.access.log main; #location / { # root html; # index index.html index.htm; #} location / { proxy_pass http://netitcast.com; proxy_redirect default; }

5.使用cmd命令重新加載配置:nginx -s reload

6.運行192.168.199.104可以通過實現預設的不同的首頁來查看每次訪問的真實站點

7.使用cmd命令關閉nginx服務:nginx -s stop

windows平臺下利用Nginx做負載均衡