<!--
   - Resin 4.0 configuration file.
   -
   - See conf/full.xml for more sample configuration, including load
   - balancing and database configuration.
  -->
<resin xmlns="http://caucho.com/ns/resin"
       xmlns:resin="urn:java:com.caucho.resin">

  <!--
     - Logging configuration for the JDK logging API.
    -->
  <log-handler name="" level="all" path="stdout:"
               timestamp="[%y-%m-%d %H:%M:%S.%s] {%{thread}} "/>

  <log-handler name="" level="all" path="/var/log/resin/jvm-server.log"
                timestamp="[%y-%m-%d %H:%M:%S.%s] {%{thread}} "
                rollover-period="1D"
                rollover-size="-1"
                rollover-count="7"
                archive-format="jvm-server.log.%Y%m%d.gz"/>

  <!--
     - level='info' for production
     - 'fine' or 'finer' for development and troubleshooting
    -->
  <logger name="com.caucho" level="info"/>

  <logger name="com.caucho.java" level="config"/>
  <logger name="com.caucho.loader" level="config"/>

  <!--
     - driver .jar files can be placed in ${resin.root}/ext-lib
     -->
  <class-loader>
    <tree-loader path="${resin.root}/ext-lib"/>
  </class-loader>
  
  <!--
     - Remote management requires at least one enabled admin user.
    -->
  <resin:AdminAuthenticator>
    <resin:import path="${__DIR__}/admin-users.xml" optional="true"/>
  </resin:AdminAuthenticator>

  <!--
     - For clustered systems, create a password in place of "changeme"
     - and uncomment the <resin-system-auth-key>.
     -->
     <resin-system-auth-key>lnx4vm</resin-system-auth-key>

  <!--
     - For production sites, change dependency-check-interval to something
     - like 600s, so it only checks for updates every 10 minutes.
    -->
  <dependency-check-interval>2s</dependency-check-interval>

  <!-- Java system-properties -->
  <system-property mail.smtp.host="127.0.0.1"/>
  <system-property mail.smtp.port="25"/>

  <!--
     - default configuration applied to all clusters
    -->
  <cluster-default>
    <!-- shared webapp jars for non-classloader-aware libraries -->
    <web-app-default>
      <class-loader>
        <library-loader path="${resin.home}/webapp-jars"/>
      </class-loader>
    </web-app-default>

    <!-- standard servlet behavior, including .jsp, .php, and WEB-INF -->
    <resin:import path="${__DIR__}/app-default.xml"/>

    <!-- enables development error pages -->
    <development-mode-error-page/>

    <!--
       - Enables the proxy cache (available in Resin Professional) 
      -->
    <resin:if test="${resin.professional}">
      <cache memory-size="64M">
       <!-- Vary header rewriting for IE -->
        <rewrite-vary-as-private/>
      </cache>
    </resin:if>
    
    <!--
       - Admin services
      -->
    <resin:DeployService/>
    <!--
        Allow resin command line interface
     -->
    <resin:RemoteAdminService/>
    <resin:ManagerService/>

    
    <resin:if test="${resin.professional}">
      <resin:AdminServices/>
    </resin:if>

    <!--
       - Configuration for the health monitoring system
      -->
    <resin:if test="${resin.professional}">
      <resin:import path="${__DIR__}/health.xml" optional="true"/>
    </resin:if>

    <!--
       - Default host configuration applied to all virtual hosts.
      -->
    <host-default>
      <access-log path="log/access.log" 
                format='%h %l %u %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"'
                rollover-period="1D"
                rollover-size="-1"
                rollover-count="14"
                archive-format="access.log.%Y%m%d.gz"/>

      <!-- creates the webapps directory for .war expansion -->
      <web-app-deploy path="webapps" versioning="true"/>

      <!--
         - Defaults applied to each web-app.
        -->
      <web-app-default>
        <prologue>
          <allow-servlet-el/>
        </prologue>

        <session-config>
	  <!--
	     - enable persistent sessions
             - <use-persistent-store/>
	    -->
          <enable-url-rewriting>false</enable-url-rewriting>
        </session-config>
     
        <!--
           - Sets max-age for cacheable pages, e.g. static pages.
          -->
        <resin:if test="${resin.professional}">
          <cache-mapping url-pattern="/" max-age="5s"/>
          <cache-mapping url-pattern="*.gif" max-age="60s"/>
          <cache-mapping url-pattern="*.jpg" max-age="60s"/>
          <cache-mapping url-pattern="*.png" max-age="60s"/>
          <cache-mapping url-pattern="*.css" max-age="60s"/>
          <cache-mapping url-pattern="*.js" max-age="60s"/>
         </resin:if>
      </web-app-default>
    </host-default>
  </cluster-default>

  <!--
     - Configures the main appliction cluster.  Load-balancing configurations
     - will also have a load-balance-tier cluster.
    -->
  <cluster id="app-tier">
    <!-- sets the content root for the cluster, relative to resin.root -->
    <root-directory>.</root-directory>

    <!-- defaults for each server, i.e. JVM -->
    <server-default>
      <!-- The http port -->
      <http address="*" port="80"/>

      <!-- SSL port configuration: -->
      <http address="*" port="443">
        <openssl>
          <certificate-file>keys/gryffindor.crt</certificate-file>
          <certificate-key-file>keys/gryffindor.key</certificate-key-file>
          <password>resinkey</password>
        </openssl>
      </http>

           <jvm-arg>-Xmx512m</jvm-arg>
           <jvm-arg>-Dcom.sun.management.jmxremote</jvm-arg>
           <jvm-arg>-Dcom.sun.management.jmxremote.port=9681</jvm-arg>
           <jvm-arg>-Dcom.sun.management.jmxremote.authenticate=false</jvm-arg>
           <jvm-arg>-Dcom.sun.management.jmxremote.ssl=false</jvm-arg>
           <jvm-arg>-agentlib:resin</jvm-arg>

      <!--
         - If starting Resin as root on Unix, specify the user name
         - and group name for the web server user.
        -->
       <user-name>www-data</user-name>
       <group-name>www-data</group-name>
    
     </server-default>

    <!-- define the servers in the cluster -->
    <server id="sahqa" address="127.0.0.1" port="6800">
    </server>

    <!-- the default host, matching any host name -->
    <host id="" root-directory=".">
      <!--
         - configures an explicit root web-app matching the
         - webapp's ROOT
        -->
      <web-app id="/" root-directory="webapps/ROOT"/>
      
      <!--
         - Administration application /resin-admin
        -->
      <web-app id="/resin-admin" root-directory="${resin.root}/doc/admin">
        <prologue>
          <resin:set var="resin_admin_external" value="true"/>
          <resin:set var="resin_admin_insecure" value="true"/>
        </prologue>
      </web-app>

      <!--
	 - Resin documentation - remove for a live site
	-->
      <web-app id="/resin-doc" root-directory="${resin.root}/doc/resin-doc"/>
      <web-app id="/GwManager" root-directory="webapps/GwManager">
                <resin:XmlAuthenticator passwordDigest="none" path="/etc/resin/gwmgr-users.xml"/>
                <resin:FormLogin>
                        <login-page>/login.jsp</login-page>
                        <error-page>/logonError.jsp</error-page>
                </resin:FormLogin>
                <resin:Allow url-pattern="/*.jsp">
                    <resin:Or>
                        <resin:IfUserInRole role="gwadmin"/>
                    </resin:Or>
                </resin:Allow>
       </web-app>
       <web-app id="/GwClient" root-directory="webapps/GwClient">
                <resin:XmlAuthenticator passwordDigest="none" path="/etc/resin/gwcli-users.xml"/>
                <resin:FormLogin>
                        <login-page>/login.jsp</login-page>
                        <error-page>/logonError.jsp</error-page>
                </resin:FormLogin>
                <resin:Allow url-pattern="/*.jsp">
                    <resin:Or>
                        <resin:IfUserInRole role="gwclient"/>
                    </resin:Or>
                </resin:Allow>
       </web-app>

         <resin:Redirect regexp="^/$" target="/html/sahadmin.html">
             <resin:IfHeader name="Host" regexp="sahqa-admin.hiw.com"/>
         </resin:Redirect>
         <resin:Redirect regexp="^/$" target="/SAHWeb/HolidexWebServlet">
             <resin:IfHeader name="Host" regexp="sahqa.hiw.com"/>
         </resin:Redirect>

      <!--
	 - <resin:LoadBalance regexp="^/load" cluster="backend-tier"/>
	 - <resin:HttpProxy regexp="^/http" address="localhost:9000"/>
	 - <resin:FastCgiProxy regexp="^/fcgi" address="localhost:9001"/>
	-->
    </host>
  </cluster>
</resin>

