如何在我的tomcat servlet中从httpd基本authentication中获取远程用户?

我已经成功地从我的httpd到Tomcatconfiguration了mod_proxy_ajp,httpd执行了SSL和基本authentication。 我需要在我的tomcat应用程序中的远程用户,所以我认为使用AJP将人口头,所以HttpServletRequest.getRemoteUser()会给我的用户名,但它是'空'。 但是HttpServletRequest.getRemoteHost()填充正确。

我需要做什么来在我的tomcat servlet中从httpd基本authentication中获取远程用户?

在StackOverflow上find答案… 通过AJP将REMOTE_USER转发给tomcat

底线是你必须添加tomcatAuthentication="false"到您的AJP连接器。

默认…

 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> 

… …变

 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" tomcatAuthentication="false" />