AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1084156
Accepted
JeremyCanfield
JeremyCanfield
Asked: 2021-11-22 02:38:23 +0800 CST2021-11-22 02:38:23 +0800 CST 2021-11-22 02:38:23 +0800 CST

HAProxy 下载 PHP 文件而不是在浏览器中显示

  • 772

我在 Docker 上运行 nginx 和 php-fpm。当使用我的 Docker 系统的主机名 (docker1.freekb.net) 时,phpinfo.php 页面会显示在浏览器中,因此我知道我已经正确配置了 nginx 和 php-fpm 以提供 PHP 页面。这是 /etc/nginx/conf.d/default.conf 中的服务器块。来自 nginx 的 80 端口的请求被转发到 PHP 的 9000 端口。

server {
    listen              80;
    server_name         stage.freekb.net;
    root                /var/www/stage;
    index               index.html phpinfo.php;
    location / {
        try_files $uri $uri/ /index.html;
    }
    location ~ \.php$ {
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_pass 0.0.0.0:9000;
        fastcgi_index phpinfo.php;
        include fastcgi_params;
    }
}

我有 HAProxy 设置以将请求转发到 nginx。这是我在 /etc/haproxy/haproxy.cfg 中的监听块。当我访问http://haproxy.freekb.net/index.html时,会显示 nginx 欢迎页面,因此我知道 HAProxy 能够将请求转发到 nginx。

但是,当我访问http://haproxy.freekb.net/phpinfo.php时,phpinfo.php 会下载到我的本地 PC。我怀疑这意味着 fastcgi 有问题。我不确定在使用 HAProxy 时要在浏览器中显示 PHP 页面需要进行哪些更改。

listen nginx
    bind *:80
    mode tcp
    balance roundrobin
    server nginx1 docker1.freekb.net:80 check
fastcgi nginx php-fpm haproxy
  • 1 1 个回答
  • 86 Views

1 个回答

  • Voted
  1. Best Answer
    JeremyCanfield
    2021-12-06T02:20:16+08:002021-12-06T02:20:16+08:00

    以防其他人找到这篇文章,我想分享我的发现。在进行 nginx/php-fpm 更改后,我没有清除我的网络浏览器缓存/历史记录。我所要做的就是清除我的网络浏览器历史记录,现在我可以在我的

    • 0

相关问题

  • Apache 在配置 eAccelerator 和 FastCGI 后从不运行

  • SCGI 或 FastCGI - 你更喜欢哪一个?[关闭]

  • Nginx 可以在别名中处理 php(或类似的 fcgi)请求吗?

  • 设置 Django 服务器以服务多个站点的最佳方式是什么?

  • PHP:FastCGI 相对于 mod_php 的优势是什么?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve