zoukankan      html  css  js  c++  java
  • nginx*初探

    1.安装nginx

    2.在nginx.conf的http区段中配置负载均衡段

    #cluser
    upstream myCluster{

    server 192.168.1.110:1300 weight=5;
    #server 192.168.1.110:8040;

    }

    #轮询负载,5/6的几率访问到192.168.1.110:1300

    3.在http区段中配置server段
    server {
           listen       80;
           server_name  192.168.1.104; #访问域名或ip

        #以下结尾的文件直接访问本地,不用代理
            location ~ .*.(gif|jpg|jpeg|png|bmp|swf|css|js)$
            {

                    root /usr/share/nginx/html;

            }

        #除以上文件外所有文件均访问代理
            location / {
                        proxy_pass              http://myCluster;#访问配置的负载,后端ip地址
                        proxy_redirect          off; //关闭后端返回的header修改

           add_header X-Cache $upstream_cache_status; // 增加缓存命中状态,使其可以在浏览器header头中看到
                         proxy_set_header       Host            $host;//修改发送到后端的header的host
                        proxy_set_header        X-Real-IP       $remote_addr; //设置真实ip
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                }
     }

  • 相关阅读:
    C++ 项目和资源导引
    C++ 类再探
    C++ 语句函数再探
    leetcode-174. Dungeon Game 地下城游戏
    34. Find First and Last Position of Element in Sorted Array + 二分
    leetcode-27. Remove Element删除元素
    git 使用入门
    MySQL数据库的启动与停止
    C++类型转换
    C++ 获取对象类型
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429449.html
Copyright © 2011-2022 走看看