我目前托管着一个用FastifyJS制作的API,并通过一个用Apache制做的反向代理.如果我直接向我的 node 服务器发出请求,一切都会正常工作,然而,对于apache(我也try 了nginx),似乎不会将响应发送到我的客户端.在判断了Apache访问日志(log)和Fastify详细模式日志(log)后,我的代理似乎没有收到来自FastifyJS的响应.
Logs from FastifyJS (verbose):个
{"level":30,"time":1706742990703,"pid":1358,"hostname":"debian","reqId":"req-2","req":{"method":"POST","url":"/files/create","hostname":"127.0.0.1:3500","remoteAddress":"127.0.0.1","remotePort":35272},"msg":"incoming request"}
{"level":30,"time":1706742990925,"pid":1358,"hostname":"debian","reqId":"req-2","res":{"statusCode":200},"responseTime":222.1608750000014,"msg":"request completed"}
{"level":30,"time":1706742990964,"pid":1358,"hostname":"debian","reqId":"req-3","req":{"method":"PUT","url":"/files/uploadChunk?transferkey=azezaqsdcdsq&chunk=0","hostname":"127.0.0.1:3500","remoteAddress":"127.0.0.1","remotePort":35272},"msg":"incoming request"}
Uploaded chunk (transferKey: azezaqsdcdsq, chunk: 0): chunkPos: 0
{"level":30,"time":1706742999872,"pid":1358,"hostname":"debian","reqId":"req-3","res":{"statusCode":201},"responseTime":8908.116479000004,"msg":"request completed"}
{"level":30,"time":1706742999908,"pid":1358,"hostname":"debian","reqId":"req-4","req":{"method":"PUT","url":"/files/uploadChunk?transferkey=azezaqsdcdsq&chunk=1","hostname":"127.0.0.1:3500","remoteAddress":"127.0.0.1","remotePort":36536},"msg":"incoming request"}
Uploaded chunk (transferKey: azezaqsdcdsq, chunk: 1): chunkPos: 1
{"level":30,"time":1706743001925,"pid":1358,"hostname":"debian","reqId":"req-4","res":{"statusCode":201},"responseTime":2017.0185090000014,"msg":"request completed"}
Logs from Apache access:个
192.168.1.* - - [01/Feb/2024:00:16:30 +0100] "POST /files/create HTTP/1.1" 200 654 "-" "Stend CLI/1.0.1"
192.168.1.* - - [01/Feb/2024:00:16:30 +0100] "PUT /files/uploadChunk?transferkey=azezaqsdcdsq&chunk=0 HTTP/1.1" 201 163 "-" "-"
192.168.1.* - - [01/Feb/2024:00:16:39 +0100] "PUT /files/uploadChunk?transferkey=azezaqsdcdsq&chunk=1 HTTP/1.1" 408 485 "-" "-"
注意:最后一个使用408失败的请求比另一个使用HTTP201成功的请求出现的时间晚几分钟.
Logs from Apache errors (debug):个
[Thu Feb 01 00:16:30.702276 2024] [authz_core:debug] [pid 1147:tid 140211841373888] mod_authz_core.c(843): [client 192.168.1.254:50962] AH01628: authorization result: granted (no directives)
[Thu Feb 01 00:16:30.702364 2024] [proxy:debug] [pid 1147:tid 140211841373888] mod_proxy.c(1511): [client 192.168.1.254:50962] AH01143: Running scheme http handler (attempt 0)
[Thu Feb 01 00:16:30.702373 2024] [proxy:debug] [pid 1147:tid 140211841373888] proxy_util.c(2568): AH00942: http: has acquired connection for (127.0.0.1:3500)
[Thu Feb 01 00:16:30.702382 2024] [proxy:debug] [pid 1147:tid 140211841373888] proxy_util.c(2626): [client 192.168.1.254:50962] AH00944: connecting http://127.0.0.1:3500/files/create to 127.
0.0.1:3500
[Thu Feb 01 00:16:30.702389 2024] [proxy:debug] [pid 1147:tid 140211841373888] proxy_util.c(2849): [client 192.168.1.254:50962] AH00947: connected /files/create to 127.0.0.1:3500
[Thu Feb 01 00:16:30.925265 2024] [proxy:debug] [pid 1147:tid 140211841373888] proxy_util.c(2584): AH00943: http: has released connection for (127.0.0.1:3500)
[Thu Feb 01 00:16:30.942604 2024] [authz_core:debug] [pid 1147:tid 140211832981184] mod_authz_core.c(843): [client 192.168.1.254:50967] AH01628: authorization result: granted (no directives)
[Thu Feb 01 00:16:30.942659 2024] [proxy:debug] [pid 1147:tid 140211832981184] mod_proxy.c(1511): [client 192.168.1.254:50967] AH01143: Running scheme http handler (attempt 0)
[Thu Feb 01 00:16:30.942667 2024] [proxy:debug] [pid 1147:tid 140211832981184] proxy_util.c(2568): AH00942: http: has acquired connection for (127.0.0.1:3500)
[Thu Feb 01 00:16:30.942676 2024] [proxy:debug] [pid 1147:tid 140211832981184] proxy_util.c(2626): [client 192.168.1.254:50967] AH00944: connecting http://127.0.0.1:3500/files/uploadChunk?tr
ansferkey=azezaqsdcdsq&chunk=0 to 127.0.0.1:3500
[Thu Feb 01 00:16:30.942686 2024] [proxy:debug] [pid 1147:tid 140211832981184] proxy_util.c(2849): [client 192.168.1.254:50967] AH00947: connected /files/uploadChunk?transferkey=azezaqsdcdsq
&chunk=0 to 127.0.0.1:3500
[Thu Feb 01 00:16:39.872914 2024] [proxy:debug] [pid 1147:tid 140211832981184] proxy_util.c(2584): AH00943: http: has released connection for (127.0.0.1:3500)
[Thu Feb 01 00:16:39.899225 2024] [authz_core:debug] [pid 1148:tid 140212025947840] mod_authz_core.c(843): [client 192.168.1.254:50973] AH01628: authorization result: granted (no directives)
[Thu Feb 01 00:16:39.899319 2024] [proxy:debug] [pid 1148:tid 140212025947840] mod_proxy.c(1511): [client 192.168.1.254:50973] AH01143: Running scheme http handler (attempt 0)
[Thu Feb 01 00:16:39.899351 2024] [proxy:debug] [pid 1148:tid 140212025947840] proxy_util.c(2568): AH00942: http: has acquired connection for (127.0.0.1:3500)
[Thu Feb 01 00:16:39.899363 2024] [proxy:debug] [pid 1148:tid 140212025947840] proxy_util.c(2626): [client 192.168.1.254:50973] AH00944: connecting http://127.0.0.1:3500/files/uploadChunk?tr
ansferkey=azezaqsdcdsq&chunk=1 to 127.0.0.1:3500
[Thu Feb 01 00:16:39.899472 2024] [proxy:debug] [pid 1148:tid 140212025947840] proxy_util.c(2849): [client 192.168.1.254:50973] AH00947: connected /files/uploadChunk?transferkey=azezaqsdcdsq
&chunk=1 to 127.0.0.1:3500
[Thu Feb 01 00:16:39.906992 2024] [proxy:debug] [pid 1148:tid 140212025947840] proxy_util.c(3321): AH02824: http: connection established with 127.0.0.1:3500 (127.0.0.1:3500)
[Thu Feb 01 00:16:39.907053 2024] [proxy:debug] [pid 1148:tid 140212025947840] proxy_util.c(3510): AH00962: http: connection complete to 127.0.0.1:3500 (127.0.0.1)
[Thu Feb 01 00:21:42.000262 2024] [proxy:error] [pid 1148:tid 140212025947840] (70007)The timeout specified has expired: [client 192.168.1.254:50973] AH02608: read request body failed to 127
.0.0.1:3500 (127.0.0.1) from 192.168.1.254 ()
[Thu Feb 01 00:21:42.000332 2024] [proxy_http:error] [pid 1148:tid 140212025947840] [client 192.168.1.254:50973] AH01097: pass request body failed to 127.0.0.1:3500 (127.0.0.1) from 192.168.
1.254 ()
[Thu Feb 01 00:21:42.000341 2024] [proxy:debug] [pid 1148:tid 140212025947840] proxy_util.c(2584): AH00943: http: has released connection for (127.0.0.1:3500)
我也试过使用Nginx,但问题有点类似.直接使用Cloudflare会导致"品牌"的HTTP Bad Gateway错误:
编辑:忘记说这个问题出现在使用Node使用Axios和/或Superagent向服务器发送请求时.我在Postman和使用相同Axios代码的浏览器上没有这个问题(然而,Axios上传文件似乎真的很慢).