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?

2 Answers
2

It is now not nginx configuration problem but your application or Jetty configuration problem. Your application, running under Jetty still 'thinks' its URL is /myapp/ not /, you should change your application configuration to use right base URL.

Theoretically the server could rewrite the links when passing the application responses back to the clients (Apache with right module can do that, I am not sure about nginx), but that is a good idea only if you cannot fix the application or server you proxy-pass to.

It sounds like your problem is in Jetty, before the application level -- if it weren't, you could use the Tuckey URL rewriting filter. Both are super easy to use. Tuckey is at http ://tuckey.org/urlrewrite/