nginx+tomcat多服务器负载均衡(https+域名访问)

需要:由于目前系统访问量过大,需要通过负载均衡来解决压力问题;
负载均衡方案:两台主机:A和B;
                         其中A主机上安装 nginx代理服务器部署应用程序_1
                         其中B主机上部署应用程序_2;
 
具体实现:
一、安装PCRE库
 1、下载pcre库(确保能在Nginx中使用正则表达式进行更灵活的配置
      pcre-8.36.tar.gz
 
 2、解压pcre库
> tar -zxvf pcre-8.36.tar.gz

 3、配置、编译、安装

> cd pcre-8.36
> ./configure && make && make install    #配置&编译&安装

二、安装NGINX

1、下载 nginx

       nginx-1.8.0.tar.gz

2、解压 nginx

> tar -zxvf nginx-1.8.0.tar.gz

3、配置

> ./configure --prefix=/home/bonc_zj/tour/nginx --sbin-path=/home/bonc_zj/tour/nginx/sbin/nginx --with-http_stub_status_module --with-http_ssl_module

4、编译及安装

> make && make install

5、nginx.conf 配置(https+域名访问)

   upstream gw{ #负载均衡配置
                server 132.151.46.136:8082 weight=1;   # 主机A weight参数表示权重值,越大被分配到的几率越大。
                server 132.151.46.136:8083 weight=1;   # 主机B
        }

    server {
        listen       8080 ssl;  #端口 
        server_name  go.zhejiang.com;  #域名
        ssl on;
        ssl_certificate     /home/bonc_zj/tour/nginx/conf/sslkey/zj.crt;  #证书
        ssl_certificate_key /home/bonc_zj/tour/nginx/conf/sslkey/zj.key;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        
        location /{
               index  index.html index.htm;
        }

        location /tour{ #项目名称
            proxy_pass http://gw/tour;
        }

 

 

 

posted @ 2018-02-28 17:56  彬儿qwb  阅读(190)  评论(0编辑  收藏  举报