Monday, 30 July 2007

mod_proxy_ajp: Simpler than mod_jk

I happened to look in my /etc/httpd/conf/conf.d directory, and there by default is a file proxy_ajp.conf . Hmmm, what is this? Well it appears to be a simpler way of mapping a piece of the apache URL space onto tomcat's AJP connector. Instead of the previous posting, I reconfigured apache using proxy_ajp.conf like so:

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
ProxyPass /blog/ ajp://localhost:8009/blojsom/blog/spout/

<VirtualHost blog.bwtaylor.com:80>
    ProxyPass /blojsom ajp://localhost:8009/blojsom
    ProxyPass / ajp://localhost:8009/blojsom/blog/spout/  
</VirtualHost>
I also went in to blojsom and changed the url properties accordingly. Note that stuff like CSS will be found under /blojsom, but the main blog can be hit directly at blog.bwtaylor.com . Or bwtaylor.com/blog . 

 I still think mod_jk is "correct" in a few circumstances where it's fine grained controls might help. Under load, mod_jk is capable of just sending the servlets and JSP to tomcat, while serving the static content itself. However, for something like my blog, letting tomcat handle static doesn't create any problems. The above is pretty darn simple and very easy to understand, so I'm going with that.

Technorati Tags:

Posted by spout at 9:35 PM in stuff about java

Getting mod_jk to work

This blog is now accessible at http://blog.bwtaylor.com . To make this work I did three things:

  1. I added blog.bwtaylor.com to my DNS
  2. I set up mod_jk and configured it to route the virtual host blog.bwtaylor.com to the AJP1.3 connector on port 8009
  3. I added a redirect in index.html at higher levels to go to the blogsom/blog/spout context path

These three steps are all you have to do to have simple apache tomcat integration so that tomcat access that is normally on port 8080 is added to the regular apache URL namespaces. 

The mod_jk setup was pretty easy. After downloading the appropriate mod_jk binary from a mirror like this one and symlinking it to the name mod_jk.so in the apache modules directory, I added this to /etc/httpd/conf/httpd.conf


 LoadModule jk_module modules/mod_jk.so 

Then I created a workers.properties file under /etc/httpd/conf like so:
# List workers
worker.list=tomcatWorker
# Define wrkr
worker.tomcatWorker.port=8009
worker.tomcatWorker.host=localhost
worker.tomcatWorker.type=ajp13
worker.tomcatWorker.cachesize=10
worker.tomcatWorker.cache_timeout=600
worker.tomcatWorker.socket_timeout=300

and finally I finished off the connection by adding mod_jk.conf under /etc/httpd/conf.d for the virtual hosting rules:
JkWorkersFile /etc/httpd/conf/workers.properties

JkShmFile     /var/log/httpd/mod_jk.shm
JkLogFile     /var/log/httpd/mod_jk.log
JkLogLevel    info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "

NameVirtualHost *:80
<VirtualHost blog.bwtaylor.com:80>
    DocumentRoot /opt/tomcat/webapps
    ErrorLog /var/log/httpd/mod_jk-error.log
    CustomLog /var/log/httpd/mod_jk-access.log common
    <LocationMatch ".*WEB-INF.*">
        AllowOverride None
        deny from all
    </LocationMatch>
    JkMount /* tomcatWorker
</VirtualHost>

 


Technorati Tags:

Posted by spout at 8:07 PM in stuff about java

Checking out JPackage

It's been a while since the last time I looked at JPackage, so I thought I look back. JPackage provides rpms of common java libraries and frameworks for linux.

I was hoping that since Java has gone GPL (98%) anyway, that JPackage would have an rpm for it. Nope. They don't even have java-1.6 at all yet. And that's my general comment on most of the things they do have... they're old. Spring? no 2.0. Struts? no 2.0. JBoss? 4.0.3 is their latest. Tomcat? no 6.0. Generally, I don't see the point -- I've already got the old packages, I generally want to install newer things. So, sorry, JPackage just isn't helping me.

Technorati Tags:

Posted by spout at 5:05 PM in stuff about java
« July »
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031