我的NginX / php-fpm / Laravel堆栈有问题。post body的内容随机出现在响应中,产生无效的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路由)。但是正如你所看到的,帖子正文出现在响应中。(随机,5次请求中有1次可以正常工作)
它不是来自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]
}
2条答案
按热度按时间6xfqseft1#
我遇到了同样的问题,并通过禁用nginx缓存解决了它:
1cosmwyk2#
我通过以下方式解决了这个问题:fastcgi_param PHP_VALUE“auto_prepend_file= \n allow_url_include=Off”;在nginx conf的位置部分。