Virtual Hosts using Hosts Directory

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
Ferg (Talk | contribs)
(New page: Category: Cookbook When you have a large site with many virtual hosts, you can use Resin's <host-deploy> tag and the hosts/ directory to manage the virtual hosts without modifying the...)
Newer edit →

Revision as of 13:58, 2 October 2010


When you have a large site with many virtual hosts, you can use Resin's <host-deploy> tag and the hosts/ directory to manage the virtual hosts without modifying the resin.xml file.

The directory structure for the virtual hosts would look something like:

/var/www
        hosts/
             www.foo.com/
                 webapps/
                    ROOT/
                    my-webapp/
             www.bar.com/
                 webapps/
                    ROOT/
                    my-other-webapp/

The hosts/ directory works just like the webapps/ directory. Resin scans the deployment directory for hosts, when it finds one, it automatically creates a new virtual host with the host contents.

Typically, a host-deploy will use a standard configuration with a host-default and web-app-default so all web-apps behave similarly.

resin.xml for hosts/ deployment

<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin">
 
  <root-directory>/var/www</root-directory>

  <cluster id="">
    <resin:import path="${__DIR__}/app-default.xml"/>

    <server id="" port="6800">
      <http port="80"/>
      <user-name>resin</user-name>
    </server>

    <host-default>
      <web-app-deploy path="webapps"/>
      <access-log path="log/access.log"/>
    </host-default>

    <host-deploy path="hosts"/>
  </cluster>
 </resin>
  • The ${resin.root} directory is /var/www
  • The app-default.xml resin:import defines standard servlet behavior like JSP, PHP and static files
  • The user-name changes to the resin user from root for security
  • The host-default configures the webapps/ directory and an access-log for every virtual host
  • The host-deploy configures the hosts/ directory in /var/www/hosts
Personal tools