Zend Server Windows - 授权标头不会传递给 PHP 脚本 [英] Zend Server Windows - Authorization header is not passed to PHP script

查看:21
本文介绍了Zend Server Windows - 授权标头不会传递给 PHP 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

mod_fcgid?

我无法确定,但似乎 Zend Server 可能使用 FCGI 将 Apache 请求分派给 PHP(例如,变量 PHP_FCGI_MAX_REQUESTS 出现在 $_SERVER).

如果这是真的,它可以解释我的问题,因为 mod_fcgid 故意隐瞒了应用程序的 Authorization 标头,请参阅 http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidpassheader

我尝试添加

FcgidPassHeader 授权

到我的 apache httpd.conf,但它只是抱怨:

无效命令FcgidPassHeader",可能拼写错误或由服务器配置中未包含的模块定义

mod_fastcgi?

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

FastCgiConfig -pass-header 授权

再次,它只是抱怨:

无效命令FastCgiConfig",可能拼写错误或由服务器配置中未包含的模块定义

解决方案

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

SetEnvIf 授权 "(.*)" HTTP_AUTHORIZATION=$1

这会向 $_SERVER 全局添加一个 HTTP_AUTHORIZATION 键,就像 Authorization 标头已被 Apache 传递一样.>

I have a PHP application which needs to perform HTTP Basic authentication independently of the containing Apache server.

On linux machines, with php installed via apt-get php, I find that the Authorization header does not appear in $_SERVER, but is available via apache_request_headers() or getallheaders().

On a Windows development machine, with Zend Server 6.1.0 / PHP 5.4, I am unable to get the Authorization header value from inside PHP by any of the above methods. How can I get its value?

mod_fcgid?

I haven't been able to determine it for sure, but it seems like Zend Server may use FCGI to dispatch Apache requests to PHP (for example, the variable PHP_FCGI_MAX_REQUESTS appears in $_SERVER).

If that were true, it would explain my problem, as mod_fcgid deliberately witholds the Authorization header from apps, see http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html#fcgidpassheader

I tried adding

FcgidPassHeader Authorization

to my apache httpd.conf, but it just complained that:

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

mod_fastcgi?

Similarly, perhaps Zend is using mod_fastcgi? Based on this page http://www.fastcgi.com/mod_fastcgi/docs/mod_fastcgi.html#FastCgiConfig I tried adding the following to my apache httpd.conf:

FastCgiConfig -pass-header Authorization

again, it just complained that:

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

解决方案

I found that I can work around this by adding the following to the apache config on Windows:

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

This adds a HTTP_AUTHORIZATION key to the $_SERVER global, just as if the Authorization header had been passed through by Apache.

这篇关于Zend Server Windows - 授权标头不会传递给 PHP 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆