gregs

helping me remember what I figure out

Deploying grails app to Jetty

| 0 comments

Short and sweet, step by step guide for creating a grails war and deploying it to your Jetty server (includes apache2 proxy steps)

  1. grails war (your app), in this case epic.war
  2. Copy to server
    CODE:
    1. scp epic.war user@server:/location

  3. On Debian the location for jetty webapps is: /var/lib/jetty/webapps
  4. Copy from upload location to the above folder (I used sudo)
  5. Change permissions:
    CODE:
    1. sudo chown jetty:adm epic-0-0.1.war

  6. created a *.xml context file in /etc/jetty/contexts, with something like this [note case is important!!]:
    CODE:
    1. <?xml version="1.0"  encoding="ISO-8859-1"?>
    2. <!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
    3. <Configure class="org.mortbay.jetty.webapp.WebAppContext">
    4.   <Set name="contextPath">/epic</Set>
    5.   <Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/epic-0-0.1.war</Set>
    6. </Configure>

  7. restart jetty :
    CODE:
    1. sudo /etc/init.d/jetty restart

    (try stop/start as well)

  8. test with :
    CODE:
    1. lynx http://localhost:8080/epic/

  9. Nice but I'd like http://localhost/epic/ so enable mod_proxy in apache if you haven't already :
    CODE:
    1. a2enmod proxy

  10. edit /etc/apache2/mods-enabled/proxy.load and if not present add at end:
    CODE:
    1. LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so

  11. edit your virtualhost conf file I am using 000-default and add:
    CODE:
    1. ProxyRequests Off
    2. <Proxy *>
    3.     Order deny,allow
    4.      Allow from all
    5. </Proxy>
    6. ProxyPass        /epic http://localhost:8080/epic
    7. ProxyPassReverse /epic http://localhost:8080/epic
    8. ProxyPreserveHost On

  12. restart apache : 
    CODE:
    1. sudo /etc/init.d/apache2 restart

  13. now you can
    CODE:
    1. lynx http://localhost/epic/

Update: I had omitted the ProxyPreserveHost On from the Apache configuration, which resulted in css, images and external javascripts not loading. It also caused an issue with accessing controllers.

Sources:

Leave a Reply

Required fields are marked *.

*