gpt4 book ai didi

php - Zend Server Windows - 授权 header 未传递给 PHP 脚本

转载 作者:可可西里 更新时间:2023-11-01 14:38:29 29 4
gpt4 key购买 nike

我有一个 PHP 应用程序,它需要独立于包含它的 Apache 服务器执行 HTTP 基本身份验证。

在 linux 机器上,通过 apt-get php 安装 php,我发现 Authorization header 没有出现在 $_SERVER 中,但可通过 apache_request_headers()getallheaders() 获得。

在 Windows 开发机器上,使用 Zend Server 6.1.0/PHP 5.4,我无法通过上述任何方法从 PHP 内部获取 Authorization header 值。我怎样才能得到它的值(value)?

mod_fcgid?

我还不能确定,但​​似乎 Zend Server 可能使用 FCGI 将 Apache 请求分派(dispatch)给 PHP(例如,变量 PHP_FCGI_MAX_REQUESTS 出现在 $ _服务器).

如果那是真的,那将解释我的问题,因为 mod_fcgid 故意从应用程序中隐藏 Authorization header ,请参阅 http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidpassheader

我尝试添加

FcgidPassHeader Authorization

到我的 apache httpd.conf,但它只是提示:

Invalid command 'FcgidPassHeader', perhaps misspelled or defined by a module not included in the server configuration

mod_fastcgi?

同样,也许 Zend 正在使用 mod_fastcgi?基于此页面 http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiConfig我尝试将以下内容添加到我的 apache httpd.conf:

FastCgiConfig -pass-header Authorization

再次,它只是提示:

Invalid command 'FastCgiConfig', perhaps misspelled or defined by a module not included in the server configuration

最佳答案

我发现我可以通过在 Windows 上的 apache 配置中添加以下内容来解决这个问题:

SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1

这增加了一个 HTTP_AUTHORIZATION $_SERVER 的关键全局性的,就好像 Authorization header 已由 Apache 传递。

关于php - Zend Server Windows - 授权 header 未传递给 PHP 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17488656/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com