Deploying grails app to Jetty
by gregs on Mar.20, 2010, under *nix, apache, debian, grails, jetty
Short and sweet, step by step guide for creating a grails war and deploying it to your Jetty server (includes apache2 proxy steps)
- grails war (your app), in this case epic.war
- Copy to server
CODE:
-
scp epic.war user@server:/location
-
- On Debian the location for jetty webapps is: /var/lib/jetty/webapps
- Copy from upload location to the above folder (I used sudo)
- Change permissions:
CODE:
-
sudo chown jetty:adm epic-0-0.1.war
-
- created a *.xml context file in /etc/jetty/contexts, with something like this [note case is important!!]:
CODE:
-
<?xml version="1.0" encoding="ISO-8859-1"?>
-
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
-
<Configure class="org.mortbay.jetty.webapp.WebAppContext">
-
<Set name="contextPath">/epic</Set>
-
<Set name="war"><SystemProperty name="jetty.home" default="."/>/webapps/epic-0-0.1.war</Set>
-
</Configure>
-
- restart jetty :
CODE:
-
sudo /etc/init.d/jetty restart
(try stop/start as well)
-
- test with :
CODE:
-
lynx http://localhost:8080/epic/
-
- Nice but I'd like http://localhost/epic/ so enable mod_proxy in apache if you haven't already :
CODE:
-
a2enmod proxy
-
- edit /etc/apache2/mods-enabled/proxy.load and if not present add at end:
CODE:
-
LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so
-
- edit your virtualhost conf file I am using 000-default and add:
CODE:
-
ProxyRequests Off
-
<Proxy *>
-
Order deny,allow
-
Allow from all
-
</Proxy>
-
ProxyPass /epic http://localhost:8080/epic
-
ProxyPassReverse /epic http://localhost:8080/epic
-
ProxyPreserveHost On
-
- restart apache :
CODE:
-
sudo /etc/init.d/apache2 restart
-
- now you can
CODE:
-
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:
April 15th, 2010 on 9:18 am
Thanks, I ended up removing all xml files in the contexts directory and naming the WAR file ROOT.war in webapps to get the app to deploy to /
Robbie