users@glassfish.java.net

Re: Multiple websites on Glassfish

From: <glassfish_at_javadesktop.org>
Date: Wed, 25 Aug 2010 16:43:02 PDT

This almost deserves a separate blog entry (maybe when I have time) but the simplest apache setup requires:

1. add "proxy" and "proxy_http" to the APACHE_MODULES line in /etc/sysconfig/apache2. This will enable proxying which is turned off by default

2. add a vhost configuration file into the /etc/apache2/vhosts.d directory. This file should end in ".conf" and will be automatically picked up by apache. The content of the file should look something like:

<VirtualHost *>
ServerName mydomain.com
ServerAlias www.mydomain.com
ServerAdmin info_at_mydomain.com

ProxyRequests Off

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
   
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

</VirtualHost>

The 8080 is the configured Glasfish listener port for the domain - change as required. There are many properties that can be configured here including SSL if you want to use https (you will not need to configure ssl on GF as this is handled by apache).

3. add any number of additional vhost files as required for additional domains.

4. check the overall apache configuration by typing:

apache2ctl -t

to check the syntax of the config files and then type:

apache2ctl -S

 to list all configured vhosts.

5. Restart apache by typing:

apache2ctl restart

6. Requests should now be proxied through apache to the configured GF instances.

Please note these instructions assume a Linux OS with a default Apache installation (we use SuSE). Minor changes may be required for different os setups - there are plenty of resources out there if you google ;-)

Hope this helps
[Message sent by forum member 'ggierer']

http://forums.java.net/jive/thread.jspa?messageID=481014