zoukankan      html  css  js  c++  java
  • NGINX负载均衡

    NGINX主服务器:192.168.128.128

    server1:192.168.128.130:80

    server2:192.168.128.131:80 

    1.安装NGINX

    yum -y install gcc pcre-devel zlib-devel openssl-devel
    tar -zxvf nginx-1.10.1.tar.gz
    cd nginx-1.10.1
    
    ./configure 
    --prefix=/usr/local/nginx 
    --with-http_realip_module 
    --with-http_sub_module 
    --with-http_gzip_static_module 
    --with-http_stub_status_module
     make && make install
    cd /usr/local/nginx
    vim /usr/local/nginx/conf/nginx.conf
    
    upstream myServer{
        server 192.168.128.130:80;
        server 192.168.128.131:80;
        }
        server {
            listen       80;
            server_name  192.168.128.128;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                proxy_pass  http://myServer;
                #proxy_set_header   Host             $host;
                #proxy_set_header   X-Real-IP        $remote_addr;  ;#防止ajax安全请求问题
                #proxy_set_header   REMOTE-HOST      $remote_addr; ;#防止ajax安全请求问
                #root   html;
                #index  index.html index.htm;
            }
    
    [root@localhost conf]# /usr/local/nginx/sbin/nginx -t
    [root@localhost conf]# /usr/local/nginx/sbin/nginx
    [root@localhost conf]# /usr/local/nginx/sbin/nginx -s stop
    

      到此  就可以了轮询 130和131了。


    yum -y install gcc pcre-devel zlib-devel openssl-develtar

    -zxvf nginx-1.10.1.tar.gz

    cd nginx-1.10.1
    ./configure --prefix=/usr/local/nginx

    --with-http_realip_module

    --with-http_sub_module

    --with-http_gzip_static_module

    --with-http_stub_status_module


    cd /usr/local/nginx

    [root@localhost conf]# /usr/local/nginx/sbin/nginx

    [root@localhost conf]# /usr/local/nginx/sbin/nginx -t

    [root@localhost conf]# /usr/local/nginx/sbin/nginx -s stop

     记得测试的时候三台机子要关闭防火墙  iptables -F

  • 相关阅读:
    JVisualVM远程监控
    周记 2014.11.22
    读取配置文件
    周记 2014.11.15
    MyBatis 逆向工程介绍
    PyTorch模型加载与保存的最佳实践
    ubuntu 服务器 php 环境简单搭建
    【重温广州读书会三青年自白,想念在深圳建会工人斗争中积极声援的他们!!】
    EventBus 3.0 的基本使用
    搭建Hexo博客
  • 原文地址:https://www.cnblogs.com/carbon3/p/5853590.html
Copyright © 2011-2022 走看看