基於Windows 配置 nginx 叢集

來源:互聯網
上載者:User

標籤:style   blog   class   c   code   java   

1、下載 nginx

    下載頁面 :

     http://nginx.org/en/download.html

   具體檔案:

     http://nginx.org/download/nginx-1.7.0.zip

   

 

2、運行 nginx

    解壓第一步下載的 nginx-1.7.0.zip 壓縮包 解壓到 c:/nginx路徑

2.1、修改監聽連接埠

  由於 80 連接埠已經配置IIS ,現修改nginx 監聽連接埠 

    server {

     listen      80;

  修改為

      listen    5000;

2.2 、修改 host

   修改系統 host (路徑:C:\Windows\System32\drivers\etc\HOSTS):

   添加配置:

   127.0.0.1 wangkun.com

 

  2.3 、啟動 cmd 命令視窗

   

?
1 2 3 4 5 6 7 8 9 10 11 12 cd C:\nginx   //  啟動  nginx start  nginx   /*    常用命令     nginx -s stop          // 停止nginx     nginx -s reload       // 重新載入設定檔     nginx -s quit          // 退出nginx   */

  在瀏覽器中 瀏覽 http://wangkun.com:5000 即可查看 nginx 歡迎介面

2.4  配置nginx 叢集

     2.4.1  配置 IIS 網站:

        web1:  127.0.0.1:5069

        web2:  127.0.0.1:5070

    2.4.2  調整nginx配置

        

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 events {     worker_connections  1024; }     http {     include       mime.types;     default_type  application/octet-stream;            upstream  wangkun.com        {            server   127.0.0.1:5069;            server   127.0.0.1:5070;        }              server     {         listen       5000;         server_name  localhost;                location / {                     proxy_pass http://wangkun.com;             proxy_redirect default;                       }                    error_page   500 502 503 504  /50x.html;         location = /50x.html {             root   html;         }                }     }

 2.4.3 驗證:

       通過瀏覽器瀏覽: http://wangkun:5000 

   

現在停止 IIS web01  ,則瀏覽的頁面就一直顯示  web02

 

 備忘:

    在生產環境中 ,可以將nginx 部署在linux上 ,有獨立的linux nginx 主機轉化請求 映射到  windows IIS上

  

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.