evanash1222 / TechBlogs

0 stars 0 forks source link

Nginx 502问题排查 (Review Nginx配置项) #4

Closed evanash1222 closed 2 years ago

evanash1222 commented 2 years ago

问题描述

i-uf6gu2e9qpdvh21rirul为一台Wordpress服务器,搭建方法参考 https://help.aliyun.com/document_detail/151691.html 其通过SLB lb-uf67nwk3l117mkje02h0y 对外提供服务。 现给SLB配置TCP四层监听,监听8080端口,后端虚拟服务器组为i-uf6gu2e9qpdvh21rirul,暴露80端口。 SLB的公网IP解析到mubi.pier39.cn域名。 问题:通过http://mubi.pier39.cn:8080访问时报错返回502。

排查过程

  1. 首先需要确定真实的报错。可以通过F12打开开发者模式或者curl -v http://mubi.pier39.cn:8080定位服务端真实的返回

image.png image.png HTTP 301: image.png

  1. 可以看到,这个状态码的含义是说我们要请求的资源不存在,因此被重定向到了mubi.pier39.cn:80。但是由于SLB的80端口并没有被监听,因此报错502。

这里可以尝试把SLB的80端口也监听到后端服务器的80端口,该问题就会消失。但是这并没有真正解决我们的问题。 image.png

  1. 接下来,我们需要搞清楚SLB:80 转发到 ECS:80 与 SLB:8080 转发到 ECS:80 到底有什么区别呢?理论上来说,SLB的四层转发就是把请求透传到后端服务器,没有做任何的加工。但是事实是这样的吗?

我们分别通过抓包(tcpdump -nni any port 80 and not net 100.64.0.0/10)和curl命令来看下: a. 两次TCP三次握手的建连都是成功的。这说明SLB已经正确把请求转发到了后端服务器,问题不是出在SLB。 image.png b. 接着往应用层的包去看,既然返回结果不同,那么请求的参数必然有所不同。比较后发现,二者的区别在于Host字段不同,导致请求的URI不同。这似乎跟我们的报错信息就能联系上了。(请求的资源不存在)


Hypertext Transfer Protocol
GET / HTTP/1.1\r\n
[Expert Info (Chat/Sequence): GET / HTTP/1.1\r\n]
Request Method: GET
Request URI: /
Request Version: HTTP/1.1
Host: mubi.pier39.cn\r\n  <---
User-Agent: curl/7.79.1\r\n
X-True-IP: 140.205.147.111\r\n
X-Real-IP: 140.205.147.111\r\n
Web-Server-Type: nginx\r\n
WL-Proxy-Client-IP: 140.205.147.111\r\n
X-Forwarded-For: 140.205.147.111\r\n
X-Forwarded-Proto: http\r\n
EagleEye-TraceId: 0bca315a16571825606783394e0182\r\n
Accept: */*\r\n
eagleeye-rpcid: 0.1\r\n
x5-uuid: 6304a34f9e75bb29cd9fd955c2846a5a\r\n
\r\n
[Full request URI: http://mubi.pier39.cn/]
[HTTP request 1/1]
[Response in frame: 15]

Hypertext Transfer Protocol
GET / HTTP/1.1\r\n
[Expert Info (Chat/Sequence): GET / HTTP/1.1\r\n]
Request Method: GET
Request URI: /
Request Version: HTTP/1.1
Host: mubi.pier39.cn:8080\r\n <---
User-Agent: curl/7.79.1\r\n
Accept: */*\r\n
\r\n
[Full request URI: http://mubi.pier39.cn:8080/]
[HTTP request 1/1]
[Response in frame: 26]

c. 如何验证我们的想法是正确的呢?这里可以使用curl命令修改一下HTTP的请求头,测试结果如下:

chenxiaoying@B-GG9JML7H-2306  ~  curl -v -H Host:mubi.pier39.cn http://mubi.pier39.cn:8080
*   Trying 47.103.21.135:8080...
* Connected to mubi.pier39.cn (47.103.21.135) port 8080 (#0)
> GET / HTTP/1.1
> Host:mubi.pier39.cn
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
  1. 接着自然而然会考虑去研究一下nginx的配置文件。但是这里走了一些弯路,我将自己所有的思路记录下来,也算review一遍nginx的各个配置项。

a. location, location字段主要用于匹配Request URI,用于展示不同的页面. b. server_name, 推荐看一下这篇官方文档 How nginx processes a request。简单来说,server_name的作用就是nginx服务会检查request header 的host字段来决定由哪个server块来handle这个请求。看这个描述,还是很符合我们的问题的。于是修改为server_name mubi.pier39.cn mubi.pier39.cn:8080,很可惜,问题仍未解决. c. 在没有思路的情况下,查看日志往往是我们的唯一选择。根据教程把nginx debug log开启,注意这里最好把SLB的健康检查暂时关闭,否则会收到海量的日志。从日志中我们看到,在抛出301状态码之前,是fastcgi模块在工作。因此将怀疑对象锁定在了fastcgi。

2022/07/07 23:11:51 [debug] 13008#0: epoll: fd:6 ev:0001 d:00007F055F478010
2022/07/07 23:11:51 [debug] 13009#0: epoll: fd:6 ev:0001 d:00007F055F478010
2022/07/07 23:11:51 [debug] 13008#0: accept on 0.0.0.0:80, ready: 0
2022/07/07 23:11:51 [debug] 13009#0: accept on 0.0.0.0:80, ready: 0
2022/07/07 23:11:51 [debug] 13008#0: posix_memalign: 000055EA32F67740:512 @16
2022/07/07 23:11:51 [debug] 13008#0: *81 accept: 101.224.185.215:41704 fd:11
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer add: 11: 60000:5736266849
2022/07/07 23:11:51 [debug] 13008#0: *81 reusable connection: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 epoll add event: fd:11 op:1 ev:80002001
2022/07/07 23:11:51 [debug] 13008#0: timer delta: 42953
2022/07/07 23:11:51 [debug] 13008#0: worker cycle
2022/07/07 23:11:51 [debug] 13008#0: epoll timer: 60000
2022/07/07 23:11:51 [debug] 13009#0: accept() not ready (11: Resource temporarily unavailable)
2022/07/07 23:11:51 [debug] 13009#0: timer delta: 42953
2022/07/07 23:11:51 [debug] 13009#0: worker cycle
2022/07/07 23:11:51 [debug] 13009#0: epoll timer: -1
2022/07/07 23:11:51 [debug] 13008#0: epoll: fd:11 ev:0001 d:00007F055F4781F0
2022/07/07 23:11:51 [debug] 13008#0: *81 http wait request handler
2022/07/07 23:11:51 [debug] 13008#0: *81 malloc: 000055EA32EC36B0:1024
2022/07/07 23:11:51 [debug] 13008#0: *81 recv: eof:0, avail:1
2022/07/07 23:11:51 [debug] 13008#0: *81 recv: fd:11 83 of 1024
2022/07/07 23:11:51 [debug] 13008#0: *81 reusable connection: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 posix_memalign: 000055EA32ECE600:4096 @16
2022/07/07 23:11:51 [debug] 13008#0: *81 http process request line
2022/07/07 23:11:51 [debug] 13008#0: *81 http request line: "GET / HTTP/1.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 http uri: "/"
2022/07/07 23:11:51 [debug] 13008#0: *81 http args: ""
2022/07/07 23:11:51 [debug] 13008#0: *81 http exten: ""
2022/07/07 23:11:51 [debug] 13008#0: *81 posix_memalign: 000055EA32F27150:4096 @16
2022/07/07 23:11:51 [debug] 13008#0: *81 http process request header line
2022/07/07 23:11:51 [debug] 13008#0: *81 http header: "Host: mubi.pier39.cn:8080"
2022/07/07 23:11:51 [debug] 13008#0: *81 http header: "User-Agent: curl/7.79.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 http header: "Accept: */*"
2022/07/07 23:11:51 [debug] 13008#0: *81 http header done
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer del: 11: 5736266849
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 rewrite phase: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 test location: "/"
2022/07/07 23:11:51 [debug] 13008#0: *81 test location: ~ ".php$"
2022/07/07 23:11:51 [debug] 13008#0: *81 using configuration "/"
2022/07/07 23:11:51 [debug] 13008#0: *81 http cl:-1 max:1048576
2022/07/07 23:11:51 [debug] 13008#0: *81 rewrite phase: 3
2022/07/07 23:11:51 [debug] 13008#0: *81 post rewrite phase: 4
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 5
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 6
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 7
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 8
2022/07/07 23:11:51 [debug] 13008#0: *81 access phase: 9
2022/07/07 23:11:51 [debug] 13008#0: *81 access phase: 10
2022/07/07 23:11:51 [debug] 13008#0: *81 access phase: 11
2022/07/07 23:11:51 [debug] 13008#0: *81 post access phase: 12
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 13
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 14
2022/07/07 23:11:51 [debug] 13008#0: *81 content phase: 15
2022/07/07 23:11:51 [debug] 13008#0: *81 content phase: 16
2022/07/07 23:11:51 [debug] 13008#0: *81 open index "/usr/share/nginx/html/wordpress/index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 internal redirect: "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 rewrite phase: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 test location: "/"
2022/07/07 23:11:51 [debug] 13008#0: *81 test location: "50x.html"
2022/07/07 23:11:51 [debug] 13008#0: *81 test location: ~ ".php$"
2022/07/07 23:11:51 [debug] 13008#0: *81 using configuration ".php$"
2022/07/07 23:11:51 [debug] 13008#0: *81 http cl:-1 max:1048576
2022/07/07 23:11:51 [debug] 13008#0: *81 rewrite phase: 3
2022/07/07 23:11:51 [debug] 13008#0: *81 post rewrite phase: 4
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 5
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 6
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 7
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 8
2022/07/07 23:11:51 [debug] 13008#0: *81 access phase: 9
2022/07/07 23:11:51 [debug] 13008#0: *81 access phase: 10
2022/07/07 23:11:51 [debug] 13008#0: *81 access phase: 11
2022/07/07 23:11:51 [debug] 13008#0: *81 post access phase: 12
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 13
2022/07/07 23:11:51 [debug] 13008#0: *81 generic phase: 14
2022/07/07 23:11:51 [debug] 13008#0: *81 http init upstream, client timer: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 epoll add event: fd:11 op:3 ev:80002005
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SCRIPT_FILENAME"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "/usr/share/nginx/html/wordpress"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "/index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SCRIPT_FILENAME: /usr/share/nginx/html/wordpress/index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "QUERY_STRING"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "QUERY_STRING: "
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "REQUEST_METHOD"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "GET"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "REQUEST_METHOD: GET"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "CONTENT_TYPE"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "CONTENT_TYPE: "
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "CONTENT_LENGTH"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "CONTENT_LENGTH: "
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SCRIPT_NAME"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "/index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SCRIPT_NAME: /index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "REQUEST_URI"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "/"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "REQUEST_URI: /"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "DOCUMENT_URI"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "/index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "DOCUMENT_URI: /index.php"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "DOCUMENT_ROOT"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "/usr/share/nginx/html/wordpress"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "DOCUMENT_ROOT: /usr/share/nginx/html/wordpress"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SERVER_PROTOCOL"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "HTTP/1.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SERVER_PROTOCOL: HTTP/1.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "REQUEST_SCHEME"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "http"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "REQUEST_SCHEME: http"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: ""
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "GATEWAY_INTERFACE"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "CGI/1.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "GATEWAY_INTERFACE: CGI/1.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SERVER_SOFTWARE"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "nginx/"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "1.16.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SERVER_SOFTWARE: nginx/1.16.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "REMOTE_ADDR"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "101.224.185.215"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "REMOTE_ADDR: 101.224.185.215"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "REMOTE_PORT"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "41704"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "REMOTE_PORT: 41704"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SERVER_ADDR"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "192.168.31.155"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SERVER_ADDR: 192.168.31.155"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SERVER_PORT"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "80"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SERVER_PORT: 80"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "SERVER_NAME"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script var: "localhost"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "SERVER_NAME: localhost"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "REDIRECT_STATUS"
2022/07/07 23:11:51 [debug] 13008#0: *81 http script copy: "200"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "REDIRECT_STATUS: 200"

2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "HTTP_HOST: mubi.pier39.cn:8080" <----

2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "HTTP_USER_AGENT: curl/7.79.1"
2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "HTTP_ACCEPT: */*"
2022/07/07 23:11:51 [debug] 13008#0: *81 http cleanup add: 000055EA32F27D20
2022/07/07 23:11:51 [debug] 13008#0: *81 get rr peer, try: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 stream socket 12
2022/07/07 23:11:51 [debug] 13008#0: *81 epoll add connection: fd:12 ev:80002005
2022/07/07 23:11:51 [debug] 13008#0: *81 connect to 127.0.0.1:9000, fd:12 #82
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream connect: -2
2022/07/07 23:11:51 [debug] 13008#0: *81 posix_memalign: 000055EA32F0BB00:128 @16
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer add: 12: 60000:5736266853
2022/07/07 23:11:51 [debug] 13008#0: *81 http finalize request: -4, "/index.php?" a:1, c:3
2022/07/07 23:11:51 [debug] 13008#0: *81 http request count:3 blk:0
2022/07/07 23:11:51 [debug] 13008#0: *81 http finalize request: -4, "/index.php?" a:1, c:2
2022/07/07 23:11:51 [debug] 13008#0: *81 http request count:2 blk:0
2022/07/07 23:11:51 [debug] 13008#0: timer delta: 4
2022/07/07 23:11:51 [debug] 13008#0: worker cycle
2022/07/07 23:11:51 [debug] 13008#0: epoll timer: 60000
2022/07/07 23:11:51 [debug] 13008#0: epoll: fd:11 ev:0004 d:00007F055F4781F0
2022/07/07 23:11:51 [debug] 13008#0: *81 http run request: "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream check client, write event:1, "/index.php"
2022/07/07 23:11:51 [debug] 13008#0: epoll: fd:12 ev:0004 d:00007F055F4782E0
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream request: "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream send request handler
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream send request
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream send request body
2022/07/07 23:11:51 [debug] 13008#0: *81 chain writer buf fl:0 s:576
2022/07/07 23:11:51 [debug] 13008#0: *81 chain writer in: 000055EA32F27D60
2022/07/07 23:11:51 [debug] 13008#0: *81 writev: 576 of 576
2022/07/07 23:11:51 [debug] 13008#0: *81 chain writer out: 0000000000000000
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer del: 12: 5736266853
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer add: 12: 60000:5736266854
2022/07/07 23:11:51 [debug] 13008#0: timer delta: 1
2022/07/07 23:11:51 [debug] 13008#0: worker cycle
2022/07/07 23:11:51 [debug] 13008#0: epoll timer: 60000
2022/07/07 23:11:51 [debug] 13008#0: epoll: fd:12 ev:2005 d:00007F055F4782E0
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream request: "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream process header
2022/07/07 23:11:51 [debug] 13008#0: *81 malloc: 000055EA32EC83B0:4096
2022/07/07 23:11:51 [debug] 13008#0: *81 recv: eof:1, avail:1
2022/07/07 23:11:51 [debug] 13008#0: *81 recv: fd:12 184 of 4096
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 01
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 06
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 01
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 9F
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 01
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record length: 159
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi parser: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi header: "Status: 301 Moved Permanently"
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi parser: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi header: "X-Powered-By: PHP/7.0.33"
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi parser: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi header: "Content-Type: text/html; charset=UTF-8"
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi parser: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi header: "X-Redirect-By: WordPress"
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi parser: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi header: "Location: http://mubi.pier39.cn/"
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi parser: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi header done
2022/07/07 23:11:51 [debug] 13008#0: *81 xslt filter header
2022/07/07 23:11:51 [debug] 13008#0: *81 posix_memalign: 000055EA32EC93C0:4096 @16
2022/07/07 23:11:51 [debug] 13008#0: *81 HTTP/1.1 301 Moved Permanently
Server: nginx/1.16.1
Date: Thu, 07 Jul 2022 15:11:51 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/7.0.33
X-Redirect-By: WordPress
Location: http://mubi.pier39.cn/

2022/07/07 23:11:51 [debug] 13008#0: *81 write new buf t:1 f:0 000055EA32EC93E0, pos 000055EA32EC93E0, size: 271 file: 0, size: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http write filter: l:0 f:0 s:271
2022/07/07 23:11:51 [debug] 13008#0: *81 http cacheable: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream process upstream
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe read upstream: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe preread: 17
2022/07/07 23:11:51 [debug] 13008#0: *81 readv: eof:1, avail:0
2022/07/07 23:11:51 [debug] 13008#0: *81 readv: 1, last:3912
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe recv chain: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe buf free s:0 t:1 f:0 000055EA32EC83B0, pos 000055EA32EC8457, size: 17 file: 0, size: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe length: -1
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 01
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 03
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 01
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 08
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record byte: 00
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi record length: 8
2022/07/07 23:11:51 [debug] 13008#0: *81 http fastcgi sent end request
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32EC83B0
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe write downstream: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 pipe write downstream done
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer: 12, old: 5736266854, new: 5736266867
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream exit: 0000000000000000
2022/07/07 23:11:51 [debug] 13008#0: *81 finalize http upstream request: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 finalize http fastcgi request
2022/07/07 23:11:51 [debug] 13008#0: *81 free rr peer 1 0
2022/07/07 23:11:51 [debug] 13008#0: *81 close http upstream connection: 12
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32F0BB00, unused: 48
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer del: 12: 5736266854
2022/07/07 23:11:51 [debug] 13008#0: *81 reusable connection: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http upstream temp fd: -1
2022/07/07 23:11:51 [debug] 13008#0: *81 http output filter "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 http copy filter: "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 image filter
2022/07/07 23:11:51 [debug] 13008#0: *81 xslt filter body
2022/07/07 23:11:51 [debug] 13008#0: *81 http postpone filter "/index.php?" 00007FFE50534100
2022/07/07 23:11:51 [debug] 13008#0: *81 http chunk: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 write old buf t:1 f:0 000055EA32EC93E0, pos 000055EA32EC93E0, size: 271 file: 0, size: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 write new buf t:0 f:0 0000000000000000, pos 000055EA3218DB16, size: 5 file: 0, size: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 http write filter: l:1 f:0 s:276
2022/07/07 23:11:51 [debug] 13008#0: *81 http write filter limit 0
2022/07/07 23:11:51 [debug] 13008#0: *81 writev: 276 of 276
2022/07/07 23:11:51 [debug] 13008#0: *81 http write filter 0000000000000000
2022/07/07 23:11:51 [debug] 13008#0: *81 http copy filter: 0 "/index.php?"
2022/07/07 23:11:51 [debug] 13008#0: *81 http finalize request: 0, "/index.php?" a:1, c:1
2022/07/07 23:11:51 [debug] 13008#0: *81 set http keepalive handler
2022/07/07 23:11:51 [debug] 13008#0: *81 http close request
2022/07/07 23:11:51 [debug] 13008#0: *81 http log handler
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 0000000000000000
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32ECE600, unused: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32F27150, unused: 56
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32EC93C0, unused: 3214
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32EC36B0
2022/07/07 23:11:51 [debug] 13008#0: *81 hc free: 0000000000000000
2022/07/07 23:11:51 [debug] 13008#0: *81 hc busy: 0000000000000000 0
2022/07/07 23:11:51 [debug] 13008#0: *81 tcp_nodelay
2022/07/07 23:11:51 [debug] 13008#0: *81 reusable connection: 1
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer add: 11: 65000:5736271867
2022/07/07 23:11:51 [debug] 13008#0: timer delta: 13
2022/07/07 23:11:51 [debug] 13008#0: worker cycle
2022/07/07 23:11:51 [debug] 13008#0: epoll timer: 65000
2022/07/07 23:11:51 [debug] 13008#0: epoll: fd:11 ev:2005 d:00007F055F4781F0
2022/07/07 23:11:51 [debug] 13008#0: *81 http keepalive handler
2022/07/07 23:11:51 [debug] 13008#0: *81 malloc: 000055EA32EC36B0:1024
2022/07/07 23:11:51 [debug] 13008#0: *81 recv: eof:1, avail:1
2022/07/07 23:11:51 [debug] 13008#0: *81 recv: fd:11 0 of 1024
2022/07/07 23:11:51 [info] 13008#0: *81 client 101.224.185.215 closed keepalive connection
2022/07/07 23:11:51 [debug] 13008#0: *81 close http connection: 11
2022/07/07 23:11:51 [debug] 13008#0: *81 event timer del: 11: 5736271867
2022/07/07 23:11:51 [debug] 13008#0: *81 reusable connection: 0
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32EC36B0
2022/07/07 23:11:51 [debug] 13008#0: *81 free: 000055EA32F67740, unused: 120
2022/07/07 23:11:51 [debug] 13008#0: timer delta: 11
2022/07/07 23:11:51 [debug] 13008#0: worker cycle
2022/07/07 23:11:51 [debug] 13008#0: epoll timer: -1
^C
[root@ECS001 nginx]# 

d. 如何验证我们的想法是正确的呢?可以改写nginx的配置文件,去除掉处理php的这块配置。可以发现服务器就能正确返回对mubi.pier39.cn:8080的请求了。 e. 综合我们前面的分析,问题大概率出在fastcgi param HTTP_HOST这里 2022/07/07 23:11:51 [debug] 13008#0: *81 fastcgi param: "HTTP_HOST: mubi.pier39.cn:8080" <---- 因此我们的想法就是需要手动指定HTTP_HOST,而不是让fastcgi由http请求去自动获取。 fastcgi_param HTTP_HOST mubi.pier39.cn; 添加上述配置后,问题恢复。