【发布时间】:2015-10-27 12:59:10
【问题描述】:
我的 Apache 设置有问题。
我安装了一个部分接受外部身份验证的 Web 应用程序:
- 我使用 Apache 来管理对我的应用程序网页的访问。
- 如果认证成功,则使用用户名设置环境变量 REMOTE_USER。
- 然后通过 HTTP 标头将用户名传递给我的应用程序,以便应用程序在用户会话中打开。
- 这主要是应用程序的 Apache 配置。我只在我的应用程序配置文件中设置了包含用户名的变量(HTTP 标头)的名称。
问题是:我可以成功验证(大部分时间),但我的 HTTP 标头设置为 null。
一些额外的细节:
- 我使用 Apache 和 mod_perl 模块(AuthenNIS + AuthzNIS + Net-NIS)通过 NIS 帐户对我的应用程序进行身份验证。
-
使用以下 Apache 配置文件,当我尝试访问我的应用程序时,我有身份验证表单,但 REMOTE_USER 标头设置为 null。
Listen 2208 <VirtualHost *:2208> RewriteEngine on DocumentRoot "/path/to/static" <Directory "/path/to/static"> Options +Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny Allow from all AuthType Basic AuthName "Authentifiez vous" PerlAuthenHandler Apache2::AuthenNIS PerlAuthzHandler Apache2::AuthzNIS PerlSetVar AllowAlternateAuth no require valid-user </Directory> RewriteEngine on RewriteRule . - [E=RU:%{LA-U:REMOTE_USER}] RequestHeader set REMOTE_USER %{RU}e RewriteRule ^/apps$ /apps/ [R] RewriteRule ^/static/style/(.*) /path/to/static/june_2007_style/blue/$1 [L] RewriteRule ^/static/scripts/(.*) /path/to/static/scripts/packed/$1 [L] RewriteRule ^/static/(.*) /path/to/static/$1 [L] RewriteRule ^/favicon.ico /path/to/static/favicon.ico [L] RewriteRule ^/robots.txt /path/to/static/robots.txt [L] RewriteRule ^(.*) http://localhost:2209$1 [P] </VirtualHost>
如果我设置 RequestHeader 设置 REMOTE_USER "username" 应用程序在相应的用户会话中打开。
要查看 REMOTE_USER 的值,我使用 Firebug Firefox 模块来显示 http 标头的值 + 我的应用程序有一个脚本来显示传递给它的变量的值。
我在 index.php 页面上测试了几乎相同的 Apache 配置,该页面显示了 http 请求中服务器变量的值。区别在于 RewriteRules。
<?PHP
foreach($_SERVER as $key_name => $key_value) {
print $key_name . " = " . $key_value . "<br>";
}
?>
在这种情况下,我得到一个带有用户名值的 REMOTE_USER 和 HTTP_REMOTE_USER。
我不明白我的问题出在哪里。
阿帕奇 2.2.31 红帽 6.5
提前致谢!
【问题讨论】:
标签: apache http authentication header