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

Centos7 nginx配置负载均衡

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

编辑配置文件

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 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 配置163 yum源

1、下载repo文件 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo2、备份并替换系统的repo文件 cp Cent...

docker容器自动启动设置

docker容器自动启动设置docker容器自动启动设置第一种方法docker ps -a然后使用命令对容器进行重启docker restart imageid这样就可以将容器设置为开机启动了第二种方...

Centos7 防火墙(firewall)常用操作

防火墙操作查看防火墙状态启动: systemctl start firewalld查看状态: systemctl status firewalld 停止:  systemctl s...

Centos7 mariadb 10.5主主复制

1.主数据库(1)vim /etc/my.cnfport=3306server-id=129log-bin=mysql-binauto_increment_increment=2auto_increm...

CentOS查看端口使用情况

netstat -ntlp   //列出所有netstat -ntlp |grep 80    //显示80端口使用信息。...