nginx负载均衡设置

upstream smallapi_staging_slb {
	ip_hash;
	server 192.168.0.1:8090 weight=2;#根据实际情况设置
	server 192.168.0.2:8090 weight=2;#根据实际情况设置
	server 192.168.0.3:8090 weight=1;#根据实际情况设置
}

# 接口请求地址 代理转发
server {
	listen 443 ssl;
	server_name staging.xxx.net;
	index index.html index.htm index.php default.html default.htm default.php;
	root  /home/xxx_staging_deploy/current/wap;
	ssl  on;
	ssl_certificate      /usr/local/nginx/conf/staging_ssl/2198692_staging.xxx.net.pem;
	ssl_certificate_key  /usr/local/nginx/conf/staging_ssl/2198692_staging.xxx.net.key;
	ssl_session_timeout  5m;
	ssl_protocols  TLSv1.1 TLSv1.2;
	ssl_ciphers HIGH:!ADH:!MD5:!RC4;
	ssl_prefer_server_ciphers on;
	#重定向
	location / {
		proxy_pass http://smallapi_staging_slb;
		proxy_set_header Host $host;
		proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-Proto https;
	}
}

# 分布式服务器 192.168.0.1和192。168.0.2和192.168.0.3均设置一遍
server {
	listen 8090;
	index index.html index.htm index.php default.html default.htm default.php;
	root  /home/xxx_staging_deploy/current/wap;
	location /{
		
	}
	include none.conf;
	error_page   404   /404.php;
	location ~ [^/]\.php(/|$) {
		try_files $uri =404;
		fastcgi_pass  unix:/tmp/php72-cgi.sock;
		fastcgi_index index.php;
		include fastcgi.conf;
	}
}

先插入代码段,然后解释下。ip都让我换成19.168.0.x了。负载转发主要做在192.168.0.1和192.168.0.2和192.168.0.3,均都在8090端口。因为地址为https访问,所以特别注意proxy_set_header X-Forwarded-Proto https; 。配置中的192.168.0.1为负载服务器,本身也为转发服务器。192.168.0.2和192.168.0.3的nginx配置雷同。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值