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

Centos7 nginx配置负载均衡

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

编辑配置文件

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 Galera cluster初始化和启动报错两例

问题一:160613  0:43:36 [Note] WSREP: Read nil XID from storage engines, skipping position init1606...

Centos7 防火墙(firewall)常用操作

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

Linux(CENTOS7) 安装 Docker + 部署OnlyOffice

1、安装dockeryum install docker -y2、启动docker服务systemctl start docker3、查看docker...

Centos7 mariadb 10.5集群式部署

Centos7 mariadb 10.5集群式部署

1、环境准备准备三台虚拟机,分别安装CentOS7-7.7。服务器A:10.88.1.14 node1服务器B:10.88.1.15 node2服务器C:10.88.1.16 node3三台虚机上关闭...

MYSQL 查看最大连接数和修改最大连接数

MySQL查看最大连接数和修改最大连接数1、查看最大连接数show variables like '%max_connections%';2、修改最大连接数set GLOBAL max...

Centos7 安装nginx服务

1、安装前准备:yum install yum-utils2、配置nginx源vim /etc/yum.repos.d/nginx.repo[nginx-stable] name=nginx&nbs...