【问题标题】:Nginx experiencing 502 gateway errors when accessing my siteNginx 访问我的站点时遇到 502 网关错误
【发布时间】:2021-04-09 05:20:27
【问题描述】:

我在访问我的网站时遇到 502 网关错误。

Ubuntu 20.04, Nginx, PHP-FPM 7.4, 虚拟机, Cloudflare

/etc/php/7.4/fpm/pool.d pastebin

/etc/php/7.4/fpm/pool.d pastepin

nginx 错误日志

2021/01/02 17:14:00 [error] 56540#56540: *248074 connect() failed (111: Connection refused) while connecting to upstream, client: 188.114.110.89, server: example.com, request: "POST /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:8000", host: "www.example.com", referrer: "https://www.example.com/"
2021/01/02 17:14:26 [error] 56540#56540: *248088 connect() failed (111: Connection refused) while connecting to upstream, client: 162.158.165.247, server: example.com, request: "POST /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:8000", host: "www.example.com", referrer: "https://www.example.com/index.php"
2021/01/02 17:15:14 [error] 56540#56540: *248098 connect() failed (111: Connection refused) while connecting to upstream, client: 162.158.134.121, server: example.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:8000", host: "www.example.com"
2021/01/02 17:15:43 [error] 56540#56540: *248109 connect() failed (111: Connection refused) while connecting to upstream, client: 188.114.110.89, server: example.com, request: "POST /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:8000", host: "www.example.com", referrer: "https://www.example.com/"

php -i 输出

https://pastebin.com/He4vUXwK

【问题讨论】:

    标签: php nginx


    【解决方案1】:

    您的 Nginx 尝试在 127.0.0.1:8000 联系 php,而您的 php 配置文件中提到了 localhost:8000run/php/php7.4-fpm.sock

    您应该运行php -i 来确定您的 php-fpm 服务器在哪个地址上接受 FastCGI 请求(套接字、本地主机或 127.0.0.1)并相应地调整您的配置(配置您的 php 侦听参数或您的 nginx fastcgi 地址)。

    注意:您的服务器可能无法正确解析 localhost127.0.0.1

    【讨论】:

    猜你喜欢
    • 2016-07-02
    • 2011-05-14
    • 2019-06-05
    • 2015-08-10
    • 1970-01-01
    • 2021-11-19
    • 2012-09-25
    • 2014-12-07
    • 2020-09-29
    相关资源
    最近更新 更多