• Nginx 作为代理服务与负载均衡



    代理服务


    代理一代为办理(代理理财、代理收货等等)

    4063500

    4121359

    4187921

    4225546


    代理区别

    区别在于代理的对象不一样

    正向代理代理的对象是客户端

    反向代理代理的对象是服务端


    反向代理配置


    server {
        listen       80;
        server_name  localhost jeson.t.imooc.io;
    
        #charset koi8-r;
        access_log  /var/log/nginx/test_proxy.access.log  main;
    
        location / {
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }
    
        location ~ /test_proxy.html$ {
           proxy_pass http://127.0.0.1:8080;
           include proxy_params;
        }
    }
    
    
    # proxy_params 参数,同目录下另一个文件保存
    
    proxy_redirect default;
    
    proxy_set_header Host $http_host;
    proxy_set_header X-Real-IP $remote_addr;
    
    proxy_connect_timeout 30;
    proxy_send_timeout 60;
    proxy_read_timeout 60;
    
    proxy_buffer_size 32k;
    proxy_buffering on;
    proxy_buffers 4 128k;
    proxy_busy_buffers_size 256k;
    proxy_max_temp_file_size 256k;
    

    正向代理

    server {
        listen       80;
        server_name  localhost jeson.t.imooc.io;
    
        #charset koi8-r;
        access_log  /var/log/nginx/test_proxy.access.log  main;
        resolver 8.8.8.8;
        location / {
            proxy_pass http://$http_host$request_uri;
        }
    }
    

    负载均衡配置

    upstream imooc {
            server 116.62.103.228:8001;
            server 116.62.103.228:8002;
            server 116.62.103.228:8003;
        }
    
    server {
        listen       80;
        server_name  localhost jeson.t.imooc.io;
    
        access_log  /var/log/nginx/test_proxy.access.log  main;
        resolver  8.8.8.8;
    
        location / {
            proxy_pass http://imooc;
            include proxy_params;
        }
    
    
    }
    
    
    # 设置权重
    upstream imooc {
            server 116.62.103.228:8001 down;
            server 116.62.103.228:8002 backup;
            server 116.62.103.228:8003 max_fails=1 fail_timeout=10s;
        }
    
    
        upstream imooc {
            server 116.62.103.228:8001;
            server 116.62.103.228:8002 weight=5;
            server 116.62.103.228:8003;
        }
    
    
    # IP hash
        upstream imooc {
            ip_hash;
            server 116.62.103.228:8001;
            server 116.62.103.228:8002;
            server 116.62.103.228:8003;
        }
    # uri hash
        upstream imooc {
            hash $request_uri;
            server 116.62.103.228:8001;
            server 116.62.103.228:8002;
            server 116.62.103.228:8003;
        }
    
    
    
  • 相关阅读:
    RAID磁盘阵列详解以及软RAID的实施部署
    Ubuntu 安装 配置 Mysql
    Asp.net页面之间传递参数的几种方法
    asp.net中网页间传递参数用什么方法比较
    Asp.net页面之间传递参数的几种方法
    asp.net中网页间传递参数用什么方法比较
    Asp.net页面之间传递参数的几种方法
    asp.net中网页间传递参数用什么方法比较
    CSS2.0中最常用的18条技巧
    Asp.net页面之间传递参数的几种方法
  • 原文地址:https://www.cnblogs.com/wenyule/p/11073106.html
Copyright © 2020-2023  润新知