Installation apache - getrailo/railo GitHub Wiki

This page is devoted to showing how you can connect the Apache Web Server to a Railo Installation.

Generally the process is to proxy the requests over, but of course, there are many ways to do this.

All of the items below require that the one or more of the following modules be uncommented:

LoadModule proxy_connect_module libexec/apache2/mod_proxy_connect.so
LoadModule proxy_ajp_module libexec/apache2/mod_proxy_ajp.so
LoadModule proxy_module libexec/apache2/mod_proxy.so
LoadModule proxy_http_module libexec/apache2/mod_proxy_http.so
LoadModule proxy_balancer_module libexec/apache2/mod_proxy_balancer.so

Simple Proxy

A simple proxy could be in your Virtual Hosts apache file (such as httpd-vhosts.conf):

<VirtualHost *:80>
  ServerName railo.corfield.org
  DocumentRoot /Users/scorfield/Sites
  
  ProxyRequests Off
	<Proxy *>
	  Order deny,allow
	  Allow from all
	</Proxy>
  ProxyPass / http://localhost:8080/
  ProxyPassReverse / http://localhost:8080/

</VirtualHost>

MOD_CFML

mod_cfml is the preferred way to connect Apache to Tomcat. It's a great way to reduce the setup for each VirtualHost you have setup. It works by passing the domain + DocumentRoot to Tomcat, which then in turn uses a mod_cfml valve to create the domain/context config for you. All you need to do is add the following in Apache:

<Proxy *>
Allow from 127.0.0.1
</Proxy>

ProxyPreserveHost On
ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2

PerlRequire "/Applications/Railo/connector/mod_cfml.pm"
PerlHeaderParserHandler mod_cfml
PerlSetVar LogHeaders false
PerlSetVar LogHandlers false
PerlSetVar CFMLHandlers ".cfm .cfc .cfml"

In your Tomcat server.xml you can then add the valve:

  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

    <Valve className="mod_cfml.core" loggingEnabled="false" waitForContext="10" />

  </Host>

Load Balanced

This would be a load balanced way for multiple instances of Tomcat

<VirtualHost *:80>
	DocumentRoot "/Users/markdrew/Sites/mydomain.local/"
	ServerName mydomain.local
	DirectoryIndex index.cfm index.cfml index.html index.htm 

	<Directory />
	Options FollowSymLinks
	AllowOverride None
	Order deny,allow
	allow from all
	</Directory>
	
	<Proxy balancer://mycluster>
	BalancerMember ajp://mydomain.local:8080/ route=node1 loadfactor=1
	BalancerMember ajp://mydomain.local:8081/ route=node2 loadfactor=1
	ProxySet lbmethod=byrequests
#	ProxySet stickysession=JSESSIONID
	</Proxy>
	ProxyPreserveHost On
	ProxyPass / balancer://mycluster/ nofailover=On

	<Location /balancer-manager>
	SetHandler balancer-manager

	Order Deny,Allow
	Deny from all
	Allow from all
	</Location>
</VirtualHost>

Handle Multiple Virtual Hosts

This entry would be placed at the top of the httpd-vhosts.conf file so that you don't have to add individual configurations to each VirtualHost entry.

NameVirtualHost *:80

<Proxy *>
Allow from 127.0.0.1
</Proxy>
ProxyPreserveHost On
 ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ ajp://localhost:8009/$1$2
#ProxyPassMatch ^/(.+\.cf[cm])(/.*)?$ http://localhost:8888/$1$2
#Uncomment the above to handle HTTP (such as with Jetty) rather than AJP

<VirtualHost *:80>
    ServerName getrailo.com
    DocumentRoot "/Users/markdrew/Sites/dev.railoserver.local"
    ServerName getrailo.com
    ServerAlias www.getrailo.com
</VirtualHost>

<VirtualHost *:80>
    ...
</VirtualHost>
⚠️ **GitHub.com Fallback** ⚠️