There so many cases why somebody might want to set Glassfish server behind Apache, that I won’t list them all.
I think that emotional aspect is the most important here – people feel uncomfortable with ports other, than traditional 80 and 443.
So, I decided, that it would be much better if our server will be not on port 8080, but in root of usual domain.
I started from a wonderful article Setting up Glassfish behind Apache
I followed the steps, listed in the article, but met some issues with setting up mod_jk modile.
Create the listener:
$GLASSFISH_HOME/glassfish/bin/asadmin --user admin --host localhost --port 4848 create-http-listener --listeneraddress 0.0.0.0 --listenerport 8009 --defaultvs server jk-connector-8009
Activate the listener:
$GLASSFISH_HOME/glassfish/bin/asadmin --user admin --host localhost --port 4848 set configs.config.server-config.network-config.network-listeners.network-listener.jk-connector-8009.jk-enabled=true
Finally, restart the Glassfish Server:
$GLASSFISH_HOME/glassfish/bin/asadmin stop-domain $GLASSFISH_HOME/glassfish/bin/asadmin start-domain
1. download sources from The Apache Tomcat Connector
3. install http-devel package
4. Configure for build
$ ./configure --with-apxs=/usr/sbin/apxs
5. Make binaries
6. Copy library to modules
$ sudo cp ./apache-2.0/mod_jk.so /usr/lib64/httpd/modules/
7. Add to the list of modules in your Apache config
LoadModule jk_module modules/mod_jk.so
Create a file called workers.properties and place it in a safe place (e.g. /etc/httpd/conf.d). Put the following contents in this file:
worker.list=worker1 worker.worker1.type=ajp13 worker.worker1.host=localhost worker.worker1.port=8009
Then, open your httpd.conf file and put the following contents in it (outside a VirtualHost section). Check the path of your workers.properties file
JkWorkersFile /path/to/workers.properties JkLogFile /var/log/httpd/mod_jk.log JkLogLevel debug JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkOptions +ForwardKeySize +ForwardURICompat -ForwardDirectories JkRequestLogFormat "%w %V %T"
Also, you need to add a VirtualHost section in your page, in order to map the specific domain/subdomain with the path in Glassfish you want to make visible through Apache:
ServerAdmin email@example.com ServerName mydomain.com ... other stuff JkMount /myapp/* worker1 ... other stuff
Set your web module in root of glassfish server
just deploy your war with the following parameter:
$GLASSFISH_HOME/bin/asadmin deploy --contextroot "/" module.war
If you want to see this configuration in action, open our “Is it kosher? search” web app.