title: apache ajp configuration for grails application
body: <p>I have multiple grails application running on a tomcat server, using the ajp protocol. On the same server I have apache running as a front end to those tomcat applications. apache configuration like this:</p>
  
  <pre><code>ProxyPass /example1/ ajp://localhost:8082/example1/
  ProxyPassReverse /example1/ ajp://localhost:8082/example1/
  ProxyPass /example2/ ajp://localhost:8082/example1/
  ProxyPassReverse /example2/ ajp://localhost:8082/example2/
  </code></pre>
  
  <p>I want example1 to run as the root context</p>
  
  <pre><code>ProxyPass / ajp://localhost:8082/example1/
  </code></pre>
  
  <p>this does not work. All Static content is broken. the web page text renders, by the images would point to: /example1/images/myimage.jpg
  the image would get resolved if you go to: /images/myimage.jpg</p>
  
  <p>I have tried many things to avoid deploying example1 as ROOT.war. but that seems to be the only way to resolve this issue. This is not sufficient for my need.</p>
  
  <p>on the grails side, I've tied removing the ${appName} from the server url, to look like:
  grails.serverURL = "http://apacheajp.example.com/"</p>
  
  <p>I've added grails.app.context=/ to application.properties, this did not work either.</p>
  
  <p>the ultimate goal here is to use this apache to server for multiple subdomains. I would want example1.example.com (a alias to apacheajp.example.com) to resolve to the example1 app. Similarly, I would want example2.example.com to act the same way for the example2 app. This explains why deploying as ROOT would be undesirable. </p>
  
  <p>the server I use is RHEL6</p>
  
  <p>this post here best describes the same issue I am having:
  <a href="http://grails.1312388.n4.nabble.com/Grails-context-big-problem-with-apache-mod-proxy-td1392448.html" rel="nofollow">http://grails.1312388.n4.nabble.com/Grails-context-big-problem-with-apache-mod-proxy-td1392448.html</a></p>