負載均衡7層nginx(提供軟體包)

技術小胖子發表於2017-11-16

負載均衡7Nginx(提供軟體包)

Nginx proxy 利用 proxy 基本可以實現一個完整的 7 層負載均衡。

Client            eth0 192.168.122.1/24

Nginx            eth0192.168.122.254/24

HTML  1        eth0 192.168.122.10/24

HTML  2        eth0 192.168.122.20/24

PHP    1         eth0 192.168.122.30/24

PHP  2          eth0 192.168.122.40/24


HTML 12

# yum install httpd

分別建立測試頁面index.html ,開啟服務


PHP  12

# yum install httpd

分別建立測試頁面index.php ,開啟服務



安裝配置Nginx

# rpm -ivh nginx-0.6.36-1.el5.i386.rpm

# vim /etc/nginx/nginx.conf

      location/ {

             root/usr/share/nginx/html;

             indexindex.html index.htm;

             if($request_uri  ~*  .html$) {

                    proxy_passhttp://htmlserver;

             }

             if($request_uri  ~*  .php$) {

                    proxy_passhttp://phpserver;

             }

      }


# vim /etc/nginx/conf.d/test.conf

upstream htmlserver {

      server192.168.122.10;

      server192.168.122.20;

      }

upstream phpserver {

      server192.168.122.30;

      server192.168.122.40;

      }


# service nginx start



在客戶端訪問 HAproxy測試

# elinks –dump http:// 192.168.122.254

# elinks –dump http://192.168.122.254/index.html

# elinks –dump http://192.168.122.254/index.php


可以只做2html進行測試訪問192.168.122.254/index.html  不停地重新整理清楚歷史記錄會分別看到html 1的網頁

軟體包看其他博文最下面的百度雲盤的地址





      本文轉自潘闊 51CTO部落格,原文連結:http://blog.51cto.com/pankuo/1389320,如需轉載請自行聯絡原作者



相關文章