nginx 做为web 服务器的一个重要功能就是反向代理,并且可做为前端负载均衡设备使用,且nginx 反向代理不需要新增额外的模块,默认自带proxy_pass 指令

具体配置如下:

#负载均衡配置,weight 代表权重
upstream uuu{
        server 192.168.3.80:9111 weight=1;
        server 192.168.3.70:9111 weight=2;
    }
server {
        listen 9100;
        location  / {
                proxy_set_header Host $host:$server_port;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header   X-Forwarded-For    $proxy_add_x_forwarded_for;
                proxy_pass http://uuu;
        }
}

proxy_pass 设置反向代理地址

upstream 负载均衡配置

proxy_set_header 设置反向代理头部信息

相关文章:

  • 2022-01-07
  • 2022-01-16
猜你喜欢
  • 2021-09-06
  • 2022-02-12
  • 2021-09-30
相关资源
相似解决方案