servlets - Password protection .htaccess like in Java web applications -
i have following scenario:
i'm developing java ee web application running on jboss 6.1.0 , want publish application on public server end-user testing.
for example: http://mysite.com/testings/app1/
my question: appropriate way protect directory in .htaccess (apache http server) fashion, so, when client try access http://mysite.com/testings/app1/ asked user/password combination?.
i think there 2 options:
- configuration on servlet server?
- reverse proxy?.
i want clarify best practice in situation, because php applications .htaccess feature fit needs.
you can use spring security that, wrote example in how do http basic auth using struts 2/ spring 3?.
or can use apache httpd server "above" jboss (using rewrites , proxy) users access site via apache, , apache forwards jboss (that listen on localhost). here example rewrite rule forward "www.mysite.com" web application "myapp" ajp connector on port 8009:
<virtualhost www.mysite.com:80 > rewriteengine on rewritecond %{http_host} www\.mysite\.com rewriterule ^/(.*)$ ajp://localhost:8009/myapp/$1 [p,qsa,l] </virtualhost>
and can use apache auth system, example protect admin/* pages:
<proxy ajp://localhost:8009/myapp/admin/* > order deny,allow allow allowoverride authconfig authtype basic authname "admin" authuserfile /etc/apache2/passwd/admin.passwd require valid-user </proxy>
Comments
Post a Comment