centos 服务器 nginx 负载均衡服务安装

1.安装必要的软件

yum -y install gcc gcc-c++ autoconf automake libtool make cmake  zlib zlib-devel openssl openssl-devel pcre-devel

2.安装nginx 基本模块

./configure  --with-http_ssl_module  --with-http_stub_status_module --with-pcre

 

2.1安装nginx增加stream模块

./configure --with-http_ssl_module --with-http_stub_status_module --with-pcre --with-stream --with-stream_ssl_preread_module --with-http_gzip_static_module

3.执行安装

make & make install

 

安装之后nginx 的路径是  /usr/local/nginx

4.在全局变量里面配置nginx的环境变量.方便以后使用nginx的命令,

vim /etc/profile 
export NGINX_HOME=/usr/local/nginx
export PATH=$NGINX_HOME/sbin:$PATH 

5.配置普通的nginx配置nginx.conf

server {
    listen 443;
    server_name _;

    ssl on;
    ssl_certificate /usr/local/nginx/conf/ssl/server.crt;
    ssl_certificate_key /usr/local/nginx/conf/ssl/server.key;

    ssl_protocols  SSLv2 SSLv3 TLSv1;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header REMOTE-HOST $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    location =/ {
            rewrite / /xxxx/;
    }
    location /aaa/{
            proxy_pass http://aaa;
    }
}

6配置流访问方式:

stream {
    
    upstream ssh {
        server xxx.xxx.xxx.xxx:22;
    }
    server {
        listen 83; 
        proxy_pass ssh;
        proxy_connect_timeout 1h;
        proxy_timeout 1h;
    }
}

 

posted @ 2019-05-15 17:19  零零柒  阅读(227)  评论(0编辑  收藏  举报