Laravel 502 错误网关错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40319340/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel 502 Bad Gateway Error
提问by sesc360
I use Laravel 5.3 with the latest Homestead Setup. When I make a POST Request to my API, I get this error according to the log file:
我使用 Laravel 5.3 和最新的 Homestead Setup。当我向我的 API 发出 POST 请求时,我根据日志文件收到此错误:
2016/10/29 12:44:34 [error] 776#0: *28 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 192.168.10.1, server: loc.medifaktor, request: "POST /api/v1/mfusers HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm.sock$
2016/10/29 12:44:34 [error] 776#0: *28 recv() failed (104: Connection reset by peer) 从上游读取响应头,客户端:192.168.10.1,服务器:loc.medifaktor,请求:“POST /api/v1/mfusers HTTP/1.1”,上游:“fastcgi://unix:/var/run/php5-fpm.sock$
I use POSTMAN to make the POST Request sending it to the URL: http://loc.medifaktor/api/v1/mfusers
我使用 POSTMAN 将 POST 请求发送到 URL: http://loc.medifaktor/api/v1/mfusers
which is a homestead installation and runs locally on my computer.
这是一个宅基地安装并在我的计算机上本地运行。
The client address mentioned in this error is 192.168.10.1 which is actually not true, as I use 192.168.10.10. Could this be the mistake and how do I change that?
这个错误中提到的客户端地址是 192.168.10.1 这实际上不是真的,因为我使用的是 192.168.10.10。这可能是错误,我该如何更改?
[![enter image description here][1]][1]
[![在此处输入图像描述][1]][1]
I am using a fresh install of Laravel and I tried other requests like GET which work fine. Just the POST Request throws this error.
我正在使用全新安装的 Laravel,我尝试了其他请求,例如 GET,它们工作正常。只是 POST 请求会引发此错误。
The php-fpm.log shows:
php-fpm.log 显示:
[29-Oct-2016 13:47:15] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
[29-Oct-2016 13:47:15] NOTICE: configuration file /etc/php5/fpm/php-fpm.conf test is successful
This is the output of the nginx config:
这是 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;
}
采纳答案by Callam
Change your fastcgi_pass
to 127.0.0.1:9000
in your website's nginx sites_enabled
conf file.
在您网站的 nginx conf 文件中更改fastcgi_pass
为。127.0.0.1:9000
sites_enabled
回答by Ben Wilson
If you recently ran sudo apt-get update and installed a new version of PHP, and use nginx, make sure you've updated your fastcgi_pass setting in /etc/nginx/sites-enabled, e.g.:
如果您最近运行了 sudo apt-get update 并安装了新版本的 PHP,并使用了 nginx,请确保您已更新 /etc/nginx/sites-enabled 中的 fastcgi_pass 设置,例如:
fastcgi_pass unix:/run/php/php7.3-fpm.sock;
You should also make sure you install the latest version of the pdo_pgsql extension.
您还应该确保安装最新版本的 pdo_pgsql 扩展。