我使用Laravel 5.3和最新的Homestead Setup。当我向我的API发出POST请求时,我会根据日志文件收到此错误:
2016/10/29 12:44:34 [错误] 776#0:* 28 recv()失败(104:连接 从上游读取响应头时,客户端: 192.168.10.1,server:loc.medifaktor,request:“POST / api / v1 / mfusers HTTP / 1.1”,上游:“fastcgi:// unix:/var/run/php5-fpm.sock$
我使用POSTMAN将POST请求发送到URL: http://loc.medifaktor/api/v1/mfusers
这是一个宅基地安装并在我的计算机上本地运行。
此错误中提到的客户端地址是192.168.10.1,实际上并非如此,因为我使用的是192.168.10.10。这可能是错误,我该如何改变呢?
[![在此处输入图像说明] [1]] [1]
我正在使用Laravel的全新安装,我尝试了其他类似GET的请求。只有POST请求会抛出此错误。
php-fpm.log显示:
[29-Oct-2016 13:47:15] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
这是nginx配置的输出:
server {
listen 80;
listen 443 ssl;
server_name loc.medifaktor;
root "/home/vagrant/Development/Source/MFServer/public";
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /var/log/nginx/loc.medifaktor-error.log error;
sendfile off;
client_max_body_size 100m;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
ssl_certificate /etc/nginx/ssl/loc.medifaktor.crt;
ssl_certificate_key /etc/nginx/ssl/loc.medifaktor.key;
}
答案 0 :(得分:3)
将您网站的nginx fastcgi_pass
配置文件中的127.0.0.1:9000
更改为sites_enabled
。
答案 1 :(得分:0)
如果您最近运行sudo apt-get update并安装了新版本的PHP,并使用nginx,请确保已在/ etc / nginx / sites-enabled中更新了fastcgi_pass设置,例如:
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
还应确保安装了最新版本的pdo_pgsql扩展。
答案 2 :(得分:0)
请记住,您的 PHP 版本必须与您指定的 fastcgi_pass fpm 匹配。短袜。例如,您的 php 版本为 7.4。那么你应该使用下面的代码。
fastcgi_pass unit:/run/php7.4-fpm.sock