OK. I finally got this to work, thanks to your help. But it sure was a pain in the arse.
The little startup I'm involved in is working on several appfuse based projects and the purpose here is to lower deployment/hosting costs. Installing a new instance of tomcat on a new host every time we want to deploy something is costly. We could use tomcat as the webserver but virtual hosting in tomcat is a pain whereas in Apache it is easy. That is, as long as your application isn't running in tomcat. The Solution: First, in order to gain use of mod_proxy_ajp, I had to download the source for http://http://government-grants.org/mirrors/apache.org/httpd/httpd-2.2.4.tar.gz apache 2.2.4 My deployment system is running CentOS 4.4. To compile: extract tarball. CD into httpd-2.2.4 extracted dir. execute: > ./configure --enable-layout=RedHat --enable-mods-shared=all > --enable-proxy --enable-proxy-ajp --enable-proxy-http > --enable-proxy-reverse > I installed it directly using 'make install'. If you are savvy with making rpms, you could use rpmbuild against the httpd.spec file included in the source distribution. You mentioned that you explode the warfile so that you can separate what you need Apache to cache. That's a lot of work and I don't think it's necessary. Here's how I've set it up: First, I add a $CATALINA_HOME/conf/httpd directory where my deployed apps will have their specific httpd config files. I set up the Apache config for virtual hosts to read configuration from that directory. In apache 2.2.4 with a RedHat layout, you need to uncomment the virtual host config line: /etc/httpd/conf/httpd.conf wrote: > > # Virtual hosts > Include /etc/httpd/conf/extra/httpd-vhosts.conf > Then in the httpd-vhosts.conf file I added this : /etc/httpd/conf/extra/httpd-vhosts.conf wrote: > > > <LocationMatch '.*WEB-INF.*'> > AllowOverride None > deny from all > </LocationMatch> > > Include /usr/local/tomcat/conf/httpd/*.conf > Then I can simply drop in a <CONTEXT>.config in the tomcat/conf/httpd directory, reload apache, and voila! My tomcat app is delivered to users in a standard virtual hosted environment. But, in order to make this work so that apache caches images and css is to add some rewrite rules to protect access and only forward certain file extensions to tomcat. By setting the apache directory location to $CATALINA_HOME/webapps/<CONTEXT>, we can accomplish this quite nicely: $TOMCAT_HOME/conf/httpd/foo.conf wrote: > > > <VirtualHost 192.168.1.4:80> > ServerName foo.foo.com > ServerAdmin [EMAIL PROTECTED] > HostNameLookups off > DocumentRoot /usr/local/tomcat/webapps/quantum > > ErrorLog logs/quantum/error_log > #I have a custom log format - you can use 'common' > CustomLog logs/quantum/access_log DBT > > # Configure VHost to set cache-control header. It would be nice if > # we could just say image/*, but, alas, we can not. The mod_expires > # module seems not to recognize glob style expressions nor regex > # expressions. > ExpiresActive On > ExpiresByType text/css "access plus 6 hours" > ExpiresByType application/x-javascript "access plus 6 hours" > ExpiresByType image/gif "access plus 6 hours" > ExpiresByType image/jpg "access plus 6 hours" > ExpiresByType image/jpeg "access plus 6 hours" > ExpiresByType image/png "access plus 6 hours" > > # This section is adding the "public" flag to the Cache-Control header > # that is generated by the above directives. Seems some browsers are > # acting stupidly. > <Files ~ "\.(gif|jpe?g|png|js|css)$"> > Header append Cache-Control public > </Files> > > <IfModule mod_rewrite.c> > RewriteEngine On > RewriteLog logs/foo/rewrite_log > RewriteLogLevel 1 > </IfModule> > > > # Make sure to use index.jsp as the index page for directories. > DirectoryIndex index.jsp > > <Directory "/usr/local/tomcat/webapps/foo"> > Options -Indexes FollowSymLinks > AllowOverride None > # This is a config of default deny > Order allow,deny > > # And this allows the access, if the AllowedAddr is set > # see: SetEnvIf > Allow from env=AllowedAddr > </Directory> > > # Special cases for acegis all "/j_security_check" requests have to be > # passed into the correct servlet > RewriteCond %{REQUEST_URI} ^/foo/j_security_check > RewriteRule ^/foo/j_security_check > ajp://localhost:8009/foo/j_security_check [P] > > RewriteCond %{REQUEST_URI} ^/j_security_check > RewriteRule ^/j_security_check > ajp://localhost:8009/foo/j_security_check [P] > > # if we don't have the context prefixed pass to correct servlet > RewriteCond %{REQUEST_URI} !^/foo/ > RewriteRule ^/(.*)\.(jsp|action|vm|html) ajp://localhost:8009/foo/$1 [P] > RewriteRule ^/j_security_check > ajp://localhost:8009/foo/j_security_check [P] > > > # If our URL is prefixed with the context > RewriteCond %{REQUEST_URI} ^/foo/ > > # strip off the context so that images and CSS and other non-jsp files > can be served via apache > RewriteRule ^/foo/(.*) /$1 [L,R] > > I hope this helps others to get their apache/tomcat integrations working. Rob van Oostrum-2 wrote: > > I hate mod_jk. I use mod_rewrite in combination with either > mod_proxy_ajp (requires Apache 2.2.x) or mod_proxy_http (if I'm stuck > with 2.0.x or below). Apache 2.2 has a load balancer module as well if > that's what you currently need mod_jk for (as well). > > Here's the proxy config template I use for Appfuse-based applications: > > RewriteEngine on > > RewriteCond %{REQUEST_URI} ^/j_security_check [OR] > RewriteCond %{REQUEST_URI} ^/.*\.jsp [OR] > RewriteCond %{REQUEST_URI} ^/.*\.html > > RewriteRule ^/(.*) ajp://localhost:8009/$1 [P] > > ProxyPassReverse / ajp://localhost:8009/ > > I use a wrapper Ant script to break things apart physically between > Apache and Tomcat (i.e. the WAR file that's deployed doesn't contain > anything that's served up by Apache). The wrapper calls build-war on > the Appfuse build, explodes the war file, deploys everything static to > Apache, and re-wars the application, excluding whatever it sent to > Apache. > > HTH > > R. > > On 3/16/07, rfisk <[EMAIL PROTECTED]> wrote: >> >> I am having trouble integrating apache and mod_jk with my appfuse app. >> >> The goal is to have multiple appfuse apps hosted as virtual hosts with >> the >> context hidden from the end user. >> >> I am able to get mod_jk and apache configured such that the site will >> come >> up properly. In order to do this, I also configure rewrite rules in >> apache >> to hide the context. >> >> However, I can never get the login/user authentication to work properly. >> >> I have a JKMount for the worker on /j_security_check but the login.jsp >> returns error="true" after login. >> >> Has anyone had any luck with this? I've searched the web but with no luck >> in >> finding a resolution. >> -- >> View this message in context: >> http://www.nabble.com/mod_jk-and-j_security_check-tf3414945s2369.html#a9516027 >> Sent from the AppFuse - User mailing list archive at Nabble.com. >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- View this message in context: http://www.nabble.com/mod_jk-and-j_security_check-tf3414945s2369.html#a10325163 Sent from the AppFuse - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
