我的Apache设置有问题。
我安装了部分接受外部身份验证的Web应用程序:
这是问题:我可以成功进行身份验证(大多数情况下)但我的HTTP标头设置为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。
我不明白我的问题在哪里。
Apache 2.2.31 RedHat 6.5
提前致谢 !
请勿使用以下内容,因为如果REMOTE_USER设置为mod_authn_ntlm(ntlm与本地计算机,请参阅https://support.microsoft.com/en-us/kb/896861)等模块,则会遇到执行阶段的问题。
RewriteCond %{LA-U:REMOTE_USER} (.+)
RewriteRule . - [E=RU:%1]
RequestHeader set X-Remote-User %{RU}e
而是使用以下方法:
RequestHeader set X-Remote-User expr=%{REMOTE_USER}
还有一个mod_ssl的解决方案
RequestHeader set X-Remote-User %{REMOTE_USER}s