Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:


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;

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

        location / {
                #root   /var/www/nginx-default;
                #index  index.html index.htm;

        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 while what it should have been is It seems to be mapping to instead of

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

share|improve this question

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.

share|improve this answer

You could also use Nginx's rewrite module.

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 ://

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.