我有一个关于Apache设置的问题。
我安装了一个部分接受外部认证的Web应用程序:
- 我使用Apache来管理对我的应用程序Web页面的访问。 - 如果认证成功,环境变量REMOTE_USER将被设置为用户的名称。 - 然后,用户名通过HTTP标头传递到我的应用程序中,以便应用程序在用户会话中打开。 - 这主要是应用程序的Apache配置。我只在我的应用程序配置文件中设置包含用户名的变量(HTTP标头)的名称。
这里的问题是:我可以成功进行身份验证(大部分时间),但我的HTTP标头设置为空。
一些额外的细节:
为了查看REMOTE_USER的值,我使用Firebug Firefox模块显示http标头的值+我的应用程序有一个脚本显示传递给它的变量的值。
我在一个显示http请求中服务器变量的值的index.php页面上测试了一个几乎相同的Apache配置。区别在于RewriteRules。
在这种情况下,我得到了一个带有用户名值的REMOTE_USER和HTTP_REMOTE_USER。
我不明白我的问题出在哪里。
Apache 2.2.31 RedHat 6.5
提前感谢!
我安装了一个部分接受外部认证的Web应用程序:
- 我使用Apache来管理对我的应用程序Web页面的访问。 - 如果认证成功,环境变量REMOTE_USER将被设置为用户的名称。 - 然后,用户名通过HTTP标头传递到我的应用程序中,以便应用程序在用户会话中打开。 - 这主要是应用程序的Apache配置。我只在我的应用程序配置文件中设置包含用户名的变量(HTTP标头)的名称。
这里的问题是:我可以成功进行身份验证(大部分时间),但我的HTTP标头设置为空。
一些额外的细节:
- I use Apache and the mod_perl modules (AuthenNIS + AuthzNIS + Net-NIS) to authenticate to my app with NIS account.
With the following Apache config file I have the authentication form when I try to access my application but the REMOTE_USER header is set to 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>
为了查看REMOTE_USER的值,我使用Firebug Firefox模块显示http标头的值+我的应用程序有一个脚本显示传递给它的变量的值。
我在一个显示http请求中服务器变量的值的index.php页面上测试了一个几乎相同的Apache配置。区别在于RewriteRules。
<?PHP
foreach($_SERVER as $key_name => $key_value) {
print $key_name . " = " . $key_value . "<br>";
}
?>
在这种情况下,我得到了一个带有用户名值的REMOTE_USER和HTTP_REMOTE_USER。
我不明白我的问题出在哪里。
Apache 2.2.31 RedHat 6.5
提前感谢!
RequestHeader set X-Remote-User expr=%{REMOTE_USER}
只适用于 Apache 2.4.10+。 - howinatorRequestHeader set X-Remote-User %{REMOTE_USER}e env=REMOTE_USER
。链接 - dma_k