当后端某机器无法连接,或者处理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. 一、Iterator 迭代器

    需求:如何不适用for循环,依次遍历出数组中每个元素? 设计原理: 代码清单: 接口类 public interface Iterator { boolean hasNext(); Object ne ...

  2. python学习day9 字符编码和文件处理

    1.字符编码 x='上' #unicode的二进制--------->编码-------->gbk格式的二进制 res=x.encode('gbk') #bytes 字节类型 print( ...

  3. tomcat端口被占用 实际上却查询不到此端口

    参考 http://www.cnblogs.com/jieliujas/p/9413064.html 1.打开PCHunter,在进程选项卡下面可以找到无法结束的进程,右键--强制结束,失败(这儿效果 ...

  4. as3.0用了视频组件,导致视频打开后就全屏,加一下代码就行

    myFlv.fullScreenTakeOver = false; fullScreenTakeOver : Boolean 舞台进入全屏模式时,FLVPlayback 组件位于所有内容的顶部并占据整 ...

  5. Codeforces977D ---Divide by three, multiply by two 深搜+map存出现的数

    传送门:点我 题意:给定n长度的序列,重排成后一个数是前一个数除以三,或者后一个数是前一个数乘二,要求输出这个序列. 思路:大力深搜,对每个数搜除3的和乘2的是否出现过,然后继续搜下去.如果有一个数搜 ...

  6. JS中DOM以及BOM

    一.bom对象 1screen对象 console.log(screen.width);// 屏幕宽度 console.log(screen.height);// 屏幕高度 console.log(s ...

  7. Codeforces Beta Round #34 (Div. 2)

    Codeforces Beta Round #34 (Div. 2) http://codeforces.com/contest/34 A #include<bits/stdc++.h> ...

  8. TDD - 登录成功和失败

    /** * Created by Administrator on 2017-04-06. */ @RunWith(SpringJUnit4ClassRunner.class)@SpringBootT ...

  9. Ionic后退刷新

    版本:Angular 1.5.3.Ionic1.3.2 一 禁用缓存,全页面刷新. 每次前进/ 后退时,控制器都会执行. 1 AngularJS ui-router路由禁用缓存 var app = a ...

  10. windows上安装Anaconda和python

    下载并安装 anaconda 先到https://www.continuum.io/downloads 下载anaconda, 现在的版本有python2.7版本和python3.5版本,下载好对应版 ...