Connect your Java App to Apache via mod_jk


If there's a need to connect a Tomcat App to Apache, so that the web application can be access directly via port 80 (instead of 8080), I always use mod_proxy_ajp as it's very easy to configure. By default it's loaded in Apache in CentOS, while in Ubuntu you still have to load manually that module.

For some reasons, mod_proxy_ajp keeps on failing. It's throwing an error message like below:

[Thu Jun 21 10:21:29 2012] [error] proxy: AJP: failed to make connection to backend: localhost
[Thu Jun 21 10:21:31 2012] [error] proxy: AJP: disabled connection for (localhost)
[Thu Jun 21 10:22:04 2012] [error] proxy: AJP: disabled connection for (localhost)
[Thu Jun 21 10:23:49 2012] [error] (111)Connection refused: proxy: AJP: attempt to connect to 127.0.0.1:8009 (localhost) failed


I just can't fix it. Weird!

So I have decided to switch to mod_jk. I have done this in Ubuntu server.

Assuming that you've already got Tomcat and Apache working in your box, to install mod_jk:
apt-get install libapache2-mod-jk

Create your workers.properties file:
vim /etc/apache2/workers.properties

Insert the following:
# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009



Configure Apache to use the worker that you have just created:
vim /etc/apache2/apache2.conf

Insert the following:
JkWorkersFile /etc/apache2/workers.properties
JkShmFile /var/log/apache2/mod_jk.shm
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "


Configure which site or URL is to be pass connected to Tomcat:
vim /etc/apache2/sites-enabled/000-default


For instance if you want to have the ROOT app from your Tomcat to be connected to Apache, insert this line:
JkMount / worker1

Enable connector port in Tomcat by uncommenting the following line in /etc/tomcat6/server.xml:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />


Restart Apache and Tomcat, that's it!






 

CVE-2012-2122 | MySQL Vulnerability

I just did a quick upgrade on 3 servers as they were vulnerable to CVE-2012-2122.
1and1 wasn't quick to send out newsletter on this, just now I have received an email from Softlayer and Mediatemple. Oh well, unmanaged is unmanaged!

Plesk: Unable to create subdomain

Earlier today my client asked me to fix his Plesk, it can't create a subdomain.
Plesk only shows some generic error message from its interface. Upon checking the Plesk logs, I found this:

Skeleton directory `/var/www/vhosts/.skel/0' does not exist

Pretty simple, it means that /var/www/vhosts/.skel/0/ directory was deleted.
The work around is to simply recreate those directories. You may just copy the default Plesk files from any of your domain:

-bash-3.2# cp -a /var/www/vhosts/my-existing-domain.com/httpdocs/ /var/www/vhosts/.skel/0/httpdocs/
-bash-3.2# cp -a /var/www/vhosts/my-existing-domain.com/httpsdocs/ /var/www/vhosts/.skel/0/httpsdocs/
-bash-3.2# cp -a /var/www/vhosts/my-existing-domain/cgi-bin /var/www/vhosts/.skel/0/cgi-bin/
-bash-3.2# cp -a /var/www/vhosts/my-existing-domain/error_docs/ /var/www/vhosts/.skel/0/error_docs
/

If you'll attempt to create the subdomain now, I'm sure it will still fail.
Because even though it failed initially, Plesk still created the subdomain but without having those default files since they did not exist (from the .sked/0/ directory).

To remove the subdomain, issue the command below:

/usr/local/psa/admin/sbin/subdomainmng --remove --subdomain-name=testsubdomain --vhost-name=yourdomain.com

Go back to Plesk. You should be able to create the subdomain now.