当前位置:首页 > 服务器系统 > Centos > 正文内容

Centos7 nginx配置负载均衡

一二三5年前 (2020-11-27)Centos724

编辑配置文件

vim /etc/nginx/conf.d/default.conf

upstream web_backends_80 {
  ip_hash; #每个请求按访问ip的hash结果分配可以解决session的问题。
  server 10.88.1.17:80;#web端1
  server 10.88.1.18:80;#web端2
}
server {
   listen    80;
   proxy_redirect off; #重定向url
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header Host $http_host;
  location / {
    proxy_pass http://web_backends_80;
  }
}

重启

systemctl restart nginx

server中加入 可以根据域名进行转发

server_name   erp.duz.cc


扫描二维码至手机访问

扫描二维码推送至手机访问。

版权声明:本文由一二三博客发布,如需转载请注明出处。

标签: Nginx
分享给朋友:

相关文章

CentOS7双网关双IP配置

CentOS7双网关双IP配置

eth0:10.88.1.22  gw :10.88.1.1    netmask:255.255.255.0eth1:10.77.1.22  gw :10.77.1.200&nb...

Centos7 LVS+Keepalived+Nginx基于DR模式构建高可用方案

Centos7 LVS+Keepalived+Nginx基于DR模式构建高可用方案

1、准备机器名称网卡0网卡1VIPlvsmaster192.218.92.185(网关:192.218.92.1)10.88.1.20(无网关)内网通信使用192.218.92.187lvsbacku...

Centos7 mariadb 10.5集群式部署常见故障处理

Centos7 mariadb 10.5集群式部署常见故障处理

1、It may not be safe to bootstrap the cluster from this node. It was not the last one一、故障现象查看mysql错误...

Centos7 使用scp命令进行数据迁移

复制文件(本地>>远程):scp -P 33699 /etc/nginx/conf.d/default.conf root@10.88.1.23:/...

centos_7 mariadb 优化参数

最大链接数 输入show variables like 'max_connections';一、修改mariadb.service vim ...

Centos7 LVS+Keepalived+Nginx基于NAT模式构建高可用方案

Centos7 LVS+Keepalived+Nginx基于NAT模式构建高可用方案

1、准备机器名称网卡0网卡1VIPlvsmaster58.218.92.185(网关:58.218.92.1)10.77.1.20(不配置网关)58.218.92.187lvsbackup58.218...