Thursday, April 18, 2013

reverse proxy for jetty 9 with nginx


========jetty 9  docs =========
http://wiki.eclipse.org/Jetty_Expanded_Webapp_Deploy
http://wiki.eclipse.org/Jetty/Howto/Configure_JNDI_Datasource
http://www.eclipse.org/jetty/documentation/current/

====== set up proxy for jetty 9 ==========
from jetty side, if you want to run at a maven webapp dir, do as follows:

1) cd ~/projects-try/ccaApp
2) mvn war:inplace (run this only if java compile is needed, jsp's gets refreshed directly)
3) add jetty-web.xml with following details under WEB-INF
you can also do setup extra things like datasource, jndi etc.,
look at url jetty 9 http://www.eclipse.org/jetty/documentation/current/
4) note the context name given here should match with the one we will put in nginx proxy-pass as follows
before close of last "}", paste folowing contents
#inside server add
sudo vi /etc/nginx/sites-available/default
sudo /etc/init.d/nginx reload

location ^~ /j9090 {
     proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://localhost:9090;
    }
5) then you can start jetty by jetty.jar or using jetty-maven-plugin too
java -jar ~/programs/jetty-9.jar --port 9090  ~/projects-try/ccaApp/src/main/webapp

6) test these both url's it should work
a) using nginx http://localhost/j9090/
b) using jetty http://localhost:9090/j9090/

No comments: