1、在HTTP下创建代理池

#新增名为portal_service_poo的代理池,后端有3台服务器的8080端口提供服务,keepalived很重要,决定http长链接连接池
upstream portal_service_pool {
                server 10.215.1.1:8080  weight=1 max_fails=0 fail_timeout=0s;;
                keepalive 100;
    }

2、在server监听下添加代理转发配置

    server {
        listen 8080;

        charset utf-8;     }
#指定访问IP URL时转发到portal池处理
        location / {
            proxy_pass http://portal_service_pool;
        }
#指定访问IP:/aaa URL时转发到aaa池处理
        location /aaa{
            # 去除aaa转发到后端
            rewrite ^/aaa/(.*) /$1 break;
            proxy_pass http://aaa_service_pool;
        }
    }

3、上述配置讲解

1、假设Nginx本机地址为192.168.1.1,当用户访问192.168.1.1时,请求转发给了portal_service_pool池里的服务器:8080端口处理 2、upstream里weight决定权重、max_failts和fail_timeout决定最大错误次数和超时时间。keepalive决定http长链接的连接池(http1、http1.1、http2的区别自行了解)

Copyright © 运维知识库 all right reserved,powered by Gitbook文件修订时间: 2023-09-19 10:45:38

results matching ""

    No results matching ""