Nginx as a proxy to Jetty

Posted by user36812 on Server Fault See other posts from Server Fault or by user36812
Published on 2010-03-08T16:29:56Z Indexed on 2010/03/08 17:21 UTC
Read the original article Hit count: 599

Filed under:
|
|
|
|

Pardon me, this is my first attempt at Nginx-Jetty instead of Apache-JK-Tomcat.

I deployed myapp.war file to $JETTY_HOME/webapps/, and the app is accessible at the url:

http://myIP:8080/myapp

I did a default installation of Nginx, and the default Nginx page is accessible at myIP

Then, I modified the default domain under /etc/nginx/sites-enabled to the following:

server {
        listen   80;
        server_name mydomain.com;

        access_log  /var/log/nginx/localhost.access.log;

        location / {
                #root   /var/www/nginx-default;
                #index  index.html index.htm;
                proxy_pass http://127.0.0.1:8080/myapp/;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   /var/www/nginx-default;
        }
}

Now I get the index page of mypp (running in jetty) when I hit myIP, which is good. But all the links are malformed. eg. The link to css is mydomain.com/myapp/css/style.css while what it should have been is mydomain.com/css/style.css. It seems to be mapping mydomain.com to 127.0.0.1:8080 instead of 127.0.0.1:8080/myapp/

Any idea what am missing? Do I need to change anything on the Jetty side too?

© Server Fault or respective owner

Related posts about nginx

Related posts about jetty