Zend服务器的Windows - 授权头不会传递到PHP脚本 [英] Zend Server Windows - Authorization header is not passed to PHP script

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

问题描述

我有需要独立地进行包含Apache服务器的HTTP基本身份验证PHP应用程序。

在Linux机器上,通过安装了PHP apt-get的PHP ,我发现授权头不出现在 $ _ SERVER ,而是通过 apache_request_headers可用() getallheaders()可以

在Windows开发计算机,与Zend服务器6.1.0 / PHP 5.4,我无法用任何上述方法从内PHP获得授权标头值。我怎样才能得到它的价值呢?

mod_fcgid?

我一直没能确定它是肯定的,但它似乎像Zend服务器可以使用FCGI派遣阿帕奇请求PHP(例如,变量 PHP_FCGI_MAX_REQUESTS 出现在 $ _ SERVER )。

如果这是真的,那就说明我的问题,因为 mod_fcgid 特意从应用witholds的授权头,看到 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头授权

再次,它只是抱怨说:

 命令无效'FastCgiConfig,也许不包括在服务器配置中的模块拼写错误或定义


解决方案

我发现我可以解决此通过添加下列Windows上的Apache的配置:

  SetEnvIf之后授权(。*)HTTP_AUTHORIZATION = $ 1

这将 HTTP_AUTHORIZATION 键的 $ _ SERVER 全球性的,就好像授权头已经被A​​pache通过。

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服务器的Windows - 授权头不会传递到PHP脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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