[英]Nginx / PHP-FPM random post body content in response
我的 NginX / php-fpm / Laravel 堆栈有问题。 帖子正文的内容随机出现在响应中,产生无效的 JSON。 请求示例:
POST / HTTP/1.1
Accept: application/json
Content-Type: application/x-www-form-urlencoded; charset=utf-8
Host: host
Connection: close
User-Agent: Paw/3.2.1 (Macintosh; OS X/11.2.1) GCDHTTPRequest
Content-Length: 9
test=test
响应:
HTTP/1.1 500 Internal Server Error
Server: nginx/1.14.0 (Ubuntu)
Content-Type: application/json
Transfer-Encoding: chunked
Connection: close
Cache-Control: no-cache, private
Date: Tue, 16 Feb 2021 07:46:25 GMT
test=test{"error_message":"The POST method is not supported for this route."}
错误是正常的(此 uri 没有 POST 路由)。 但如您所见,帖子正文出现在响应中。 (随机,五分之一的请求可以正常工作)
它不是来自 Laravel 堆栈,我通过在 index.php 顶部设置一个 var_dump / die 来测试它(在 Laravel 加载之前)和同样的问题。
有什么见解吗?
谢谢你。
啊,也许我的 NginX 配置:
server {
access_log /var/log/nginx/access;
error_log /var/log/nginx/error;
root /root/devs/peps/www/public;
index index.php index.html index.htm index.nginx-debian.html;
server_name server_name;
underscores_in_headers on;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME /var/www/html/public$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9002;
}
listen [::]:443 ssl;
listen 443 ssl;
ssl_certificate [path to cert]
ssl_certificate_key [path to privkey]
}
我遇到了同样的问题并通过禁用 nginx 缓存来解决它:
location / {
proxy_no_cache 1;
proxy_cache_bypass 1;
#.......
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.