当后端某机器无法连接,或者处理fastcgi请求时异常退出,nginx会将fastcgi请求发送到另外一台机器。

配置文件

http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; upstream backend { //配置后端机器
server 192.168.22.103:9000;
server 172.28.250.130:9901;
} server {
listen 8099;
upstream backend {
server 192.168.22.103:9000;
server 172.28.250.130:9901;
}
....... # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass backend; //指定到后端机器
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
} ...............

2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream request: "/aa.php?"
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream process header
2017/10/11 11:12:21 [debug] 24481#0: *66 malloc: 0000000006717E30:4096
2017/10/11 11:12:21 [debug] 24481#0: *66 recv: fd:4 0 of 4096
2017/10/11 11:12:21 [error] 24481#0: *66 upstream prematurely closed connection while reading response header from upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://192.168.22.103:9000", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 http next upstream, 2
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer 2 4
2017/10/11 11:12:21 [warn] 24481#0: *66 upstream server temporarily disabled while reading response header from upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://192.168.22.103:9000", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer failed: 0000000006738850 0
2017/10/11 11:12:21 [debug] 24481#0: *66 close http upstream connection: 4
2017/10/11 11:12:21 [debug] 24481#0: *66 free: 00000000066F71D0, unused: 48
2017/10/11 11:12:21 [debug] 24481#0: *66 event timer del: 4: 1507691601518
2017/10/11 11:12:21 [debug] 24481#0: *66 reusable connection: 0
2017/10/11 11:12:21 [debug] 24481#0: *66 get rr peer, try: 1
2017/10/11 11:12:21 [debug] 24481#0: *66 get rr peer, current: 00000000067388F8 0
2017/10/11 11:12:21 [debug] 24481#0: *66 stream socket 4
2017/10/11 11:12:21 [debug] 24481#0: *66 epoll add connection: fd:4 ev:80000005
2017/10/11 11:12:21 [debug] 24481#0: *66 connect to 172.28.250.130:9901, fd:4 #68
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream connect: -2
2017/10/11 11:12:21 [debug] 24481#0: *66 posix_memalign: 00000000066F71D0:128 @16
2017/10/11 11:12:21 [debug] 24481#0: *66 event timer add: 4: 60000:1507691601519
2017/10/11 11:12:21 [debug] 24481#0: epoll: stale event 00002AD1E49F92B0
2017/10/11 11:12:21 [debug] 24481#0: timer delta: 1
2017/10/11 11:12:21 [debug] 24481#0: worker cycle
2017/10/11 11:12:21 [debug] 24481#0: epoll timer: 60000
2017/10/11 11:12:21 [debug] 24481#0: epoll: fd:4 ev:0019 d:00002AD1E49F92B1
2017/10/11 11:12:21 [debug] 24481#0: epoll_wait() error on fd:4 ev:0019
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream request: "/aa.php?"
2017/10/11 11:12:21 [debug] 24481#0: *66 http upstream process header
2017/10/11 11:12:21 [error] 24481#0: *66 connect() failed (111: Connection refused) while connecting to upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://172.28.250.130:9901", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 http next upstream, 2
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer 1 4
2017/10/11 11:12:21 [warn] 24481#0: *66 upstream server temporarily disabled while connecting to upstream, client: 192.168.22.103, server: localhost, request: "GET /aa.php HTTP/1.1", upstream: "fastcgi://172.28.250.130:9901", host: "172.28.250.184:8099"
2017/10/11 11:12:21 [debug] 24481#0: *66 free rr peer failed: 00000000067388F8 0
2017/10/11 11:12:21 [debug] 24481#0: *66 finalize http upstream request: 502
2017/10/11 11:12:21 [debug] 24481#0: *66 finalize http fastcgi request
2017/10/11 11:12:21 [debug] 24481#0: *66 close http upstream connection: 4
2017/10/11 11:12:21 [debug] 24481#0: *66 free: 00000000066F71D0, unused: 48
2017/10/11 11:12:21 [debug] 24481#0: *66 event timer del: 4: 1507691601519
2017/10/11 11:12:21 [debug] 24481#0: *66 reusable connection: 0
2017/10/11 11:12:21 [debug] 24481#0: *66 http finalize request: 502, "/aa.php?" a:1, c:1
2017/10/11 11:12:21 [debug] 24481#0: *66 http special response: 502, "/aa.php?"
2017/10/11 11:12:21 [debug] 24481#0: *66 internal redirect: "/50x.html?"

nginx fastcgi负载均衡的更多相关文章

  1. nginx+tomcat负载均衡

    最近练习nginx+tomcat负载均衡.根据一些资料整理了大体思路,最终实现了1个nginx+2个tomcat负载均衡. 安装JDK 1>进入安装目录,给所有用户添加可执行的权限 #chmod ...

  2. 使用Nginx实现负载均衡

    使用Nginx实现负载均衡 一.nginx简介 nginx是一个高性能的HTTP服务器和反向代理服务器.它起初是俄罗斯人Igor Sysoev开发的,至今支撑者俄罗斯的很多大型的网站. 二.nginx ...

  3. linux+nginx+tomcat负载均衡,实现session同步

    linux+nginx+tomcat负载均衡,实现session同步 花了一个上午的时间研究nginx+tomcat的负载均衡测试,集群环境搭建比较顺利,但是session同步的问题折腾了几个小时才搞 ...

  4. nginx+tomcat负载均衡策略

    測试环境均为本地,測试软件为: nginx-1.6.0,apache-tomcat-7.0.42-1.apache-tomcat-7.0.42-2.apache-tomcat-7.0.42-3 利用n ...

  5. 利用nginx实现负载均衡和动静分离

    1.Nginx介绍 Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器 . Nginx 是由 ...

  6. Nginx+Keepalived负载均衡高可用

    Nginx+Keepalived负载均衡高可用方案: Nginx 使用平台:unix.linux.windows. 功能: A.www web服务  http 80 b.负载均衡(方向代理proxy) ...

  7. Nginx实现负载均衡功能

    一.什么是Nginx? Nginx是一款轻量级的Web 服务器.反向代理服务器.电子邮件(IMAP/POP3)代理服务器. 二.Nginx的优点: 高并发连接:官方测试Nginx能够支撑5万并发连接, ...

  8. 若依项目利用nginx实现负载均衡及保持会话

    记录一下若依项目利用nginx实现负载均衡及保持会话的步骤. 此次作为试验性的测试,为了方便在本地window的环境上实现. 具体步骤: 1.安装两个tomcat8,可以下载一个后,另一个复制即可,下 ...

  9. nginx做负载均衡和tomcat简单集群

    Nginx做负载均衡和TOMCAT简单集群                1.下载安装nginx及其依赖包                                               ...

随机推荐

  1. 检查WMI协议是否通的

    在APM上的运行执行“wbemtest”,然后在上面的root\sivm前面加RPC不通的机器,先查WMI协议是否是通的

  2. javascript学习笔记(四):DOM操作HTML

    当网页被加载时,浏览器会创建页面的文档对象模型Document Object Model,简称DOM Dom操作html 1:改变页面中所有HTML元素 2:改变页面中所有HTML属性 3:改变页面中 ...

  3. 如何搭建python+selenium2+eclipse的环境

    搭建python和selenium2的环境(windows) 1.下载并安装python(我用的是2.7的版本) 可以去python官网下载安装:http://www.python.org/getit ...

  4. python print 美化

    本来是按照百度搜到的教程来为print输出添加颜色 然后bing了下,已经有封装好的包了,就是python-blessings 效果如图 API网址:https://blessings.readthe ...

  5. linux之docker学习

    1.redis主从同步 可以主从数据同步,从库只读,只能手动切换主备关系2.redis哨兵 -准备redis主从数据库环境 -准备redis哨兵(可以有一个,可以有多个) -哨兵检测redis主库状态 ...

  6. navicat连接虚拟机中mysql"Access denied for user'root'@'IP地址'"问题

    登陆要链接的服务器上的mysql 命令:mysql -uroot -p123456 然后执行 GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED ...

  7. 民生银行十五年的数据体系建设,深入解读阿拉丁大数据生态圈、人人BI 是如何养成的?【转】

    早在今年的上半年我应邀参加了由 Smartbi 主办的一个小型数据分析交流活动,在活动现场第一次了解到了民生银行的阿拉丁项目.由于时间关系,嘉宾现场分享的内容非常有限.凭着多年对行业研究和对解决方案的 ...

  8. Java_10 继承

    1 继承的好处 继承的出现提高了代码的复用性,提高软件开发效率. 继承的出现让类与类之间产生了关系,提供了多态的前提. 2 继承的注意事项 在Java中,类只支持单继承,不允许多继承,也就是说一个类只 ...

  9. JSP中的数据库操作,MySQL基础操作(一)

    一.JDBC JDBC(java data base concectivity),是一种用于执行SQL语句的java API,可以为多种关系库提供统一访问. 通常使用JDBC完成以下操作: 1)同数据 ...

  10. vue路由传值方式

    打印this.$route显示结果: 跳转路由传递参数如下 this.$router.push({ name: 'Page', query/params: { key: value }) <ro ...