1
votes

I've successfully configured Apache to listen over SSL/443 and proxy Tomcat listening on HTTP/8080. I have also set up basic authentication in Apache.

Once the user connects to my Tomcat servlet, will the HttpServletRequest.getRemoteUser() be populated or null. If null, how might I get the remote user?

2
Are you using mod_proxy or mod_proxy_ajp? - larsks
@larsks I'm using mod_proxy. - dacracot

2 Answers

0
votes

The simplest solution may be to use mod_proxy_ajp, which in addition to proxying requests also transfers a variety of metadata to Tomcat, including authentication information such as REMOTE_USER.

These docs for Alfresco discuss this configuration, which includes changes on both the Tomcat side (so that it knows to trust the forwarded authentication) and the Apache side.

If you're using a generic http proxy like mod_proxy, you would need to arrange for Apache to add the value of REMOTE_USER to the request (possibly as an X- header), and then arrange for your Tomcat application to recognize and trust that header (and you would obviously need to arrange for your front-end proxy to strip that header from any incoming requests).

I don't know how you would do this on the tomcat side, but this post seems to have some suggestions.

0
votes

I needed to add

<Location />
    Order allow,deny
    Allow from all
    RequestHeader unset Authorization
</Location>

to the wrapping location, the RequestHeader being the specialty that fixed it.

I found this (again) via http://codeblow.com/questions/remove-fundamental-authentication-header-with-apache-mod-proxy/ - don't know where I originally found it last year, it was a last measure for some security issue.