I have a number of web applications running in a Tomcat instance.
They are fronted by an Apache instance, using mod_proxy.
Each web application is a silo in and of itself, each with its own user credential store and user authentication and authorisation. I want to continue using that.
However, I would like to apply simple password protection at the Apache level - maybe just a single known username/password using Basic Auth - before the requests are forwarded on to the Tomcat instance. Is this possible? and how can this be done?
mod_proxy , the main proxy module Apache module for redirecting connections; it allows Apache to act as a gateway to the underlying application servers.
The "ProxyPass" and "ProxyPassReverse" parameters are used to tell Apache how to proxy requests. They require the "mod_proxy.so" and "mod_proxy_http.so" Apache modules, which are loaded by default in RHEL5 and RHEL6, but check the following lines are uncommented in the "/etc/httpd/conf/httpd. conf" file to make sure.
You can do this within the <Location>
directive
Example:
ProxyPass /mytomcatapp http://localhost:8080/app1
<Location /mytomcatapp>
AuthType Basic
AuthName "Wrapper auth"
AuthBasicProvider file
AuthUserFile "/path/to/users.htpasswd"
Require valid-user
</Location>
This will give you HTTP Basic Auth when hitting yoursite.com/mytomcatapp
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With