zoukankan      html  css  js  c++  java
  • Nginx负载均衡配置

    Nginx负载均衡配置

    介绍

    这里只是简单负载均衡配置,主要用到IP哈希和权重

    准备

    两台服务器,并安装好nginx,如果不知道怎么安装,可以看我前面写的一篇Nginx安装教程https://www.cnblogs.com/huihui-hui/p/14544034.html

    实践

    两台nginx都这么配置即可,用户访问时会根据IP和权限选择访问的服务器

    upstream temp_admin_server{
      ip_hash;
      server 主IP weight=20; #这里服务如果刚好也是这台,可直接使用127.0.0.1
      server 另外一台IP weight=10;
    }
    
    server {
            listen       80;
            server_name  localhost;
    
            server_name_in_redirect off;
            proxy_set_header Host $host:$server_port;
            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;
            fastcgi_connect_timeout 1200;
    	client_max_body_size 50m;
            location /temp-admin {
               proxy_pass http://temp_admin_server/temp-admin;                                              
            }
    }  
  • 相关阅读:
    百度多图上传
    uploadify--上传文件控件
    JS获取时间
    CSS选择器
    派大星博客的美化之路
    百度地图--JS版
    css实现元素下出现横线动画
    盒模型显隐、定位与流式布局思想
    css进度条
    Build Sharepoint 2013 Farm
  • 原文地址:https://www.cnblogs.com/huihui-hui/p/14732444.html
Copyright © 2011-2022 走看看