Virtual Hosts using Hosts Directory

From Resin 3.0

(Difference between revisions)
Jump to: navigation, search
 
Line 1: Line 1:
 +
{{Cleanup}}
 
[[Category: Cookbook]]
 
[[Category: Cookbook]]
  

Latest revision as of 19:07, 2 December 2011

40px-Edit-clear.png This article requires cleanup and may refer to a legacy version of Resin.

Please visit http://www.caucho.com/documentation/ for the most up-to-date documentation.

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>

    <proxy-cache/>

    <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