title: How do I configure nginx as proxy to jetty?
body: <p>I've been trying to set up nginx as proxy to jetty. I want to do something as explained in <a href="https://stackoverflow.com/questions/20632987/how-to-serve-clojure-pages-with-nginx/20637601#20637601">this answer</a> but for Jetty not ring.</p>
  
  <p>I've created a <code>.war</code> and I placed it in <code>~/jetty/jetty-dist/webapps/web_test-0.1.0-SNAPSHOT-standalone.war</code></p>
  
  <p>Say, I want to use the domain example.com with ip address 198.51.100.0.</p>
  
  <p>I've also copied <code>/etc/nginx/sites-available/default</code> into the file <code>example.com</code> and I have it in the same directory.</p>
  
  <p>Can you help me configure nginx as proxy to jetty in my case? I know there are many references online about how to do this but they are all different and I got confused.</p>
  
  <p>What specific changes do I need to make in nginx? What changes do I need to make in jetty.xml? Do I need to make any other changes? Will my app be served at example.com/index.html?</p>
  
  <p>Current state of nginx is copied below:</p>
  
  <pre><code>upstream jetty {
    server 127.0.0.1:8080 fail_timeout=0
  }
  
  server {
          listen 80 default_server;
          #listen [::]:80 default_server ipv6only=on;
  
          root /usr/share/nginx/html;
          index index.html index.htm;
  
          server_name localhost;
  
          location / {
                  proxy_pass http://jetty
  
                  try_files $uri $uri/ =404;
          }
  </code></pre>
  
  <hr>
  
  <p><strong>EDIT</strong></p>
  
  <p>I was wondering if I need to use Jetty at all. In <a href="http://www.reddit.com/r/Clojure/comments/1mrsmx/whats_the_common_way_to_use_ring/ccciqhx" rel="noreferrer">this setup</a> he just uses ring, which seems super easy? What do I gain by using jetty?</p>
  
  <hr>