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

Centos7 nginx配置负载均衡

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

编辑配置文件

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数据库的数据目录修改

1、查看MySQL/MariaDB数据库的数据目录MariaDB [(none)]> select @@datadir;+-----------------+| @@datadir ...

Centos7 mariadb 10.5主主复制

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

CentOS7 配置163 yum源

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

centos_7 mariadb 的最大连接数max_connections修改

输入show variables like 'max_connections'; 一、修改mariadb.service vim /us...

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...

CentOS查找文件内容命令

grep -rn "内容" /目录...