How do I configure nginx as proxy to jetty?

I've been trying to set up nginx as proxy to jetty. I want to do something as explained in this answer but for Jetty not ring.

I've created a .war and I placed it in ~/jetty/jetty-dist/webapps/web_test-0.1.0-SNAPSHOT-standalone.war

Say, I want to use the domain example.com with ip address 198.51.100.0.

I've also copied /etc/nginx/sites-available/default into the file example.com and I have it in the same directory.

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.

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?

Current state of nginx is copied below:

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; }

EDIT

I was wondering if I need to use Jetty at all. In this setup he just uses ring, which seems super easy? What do I gain by using jetty?

首页 - Wiki
Copyright © 2011-2024 iteam. Current version is 2.125.1. UTC+08:00, 2024-05-17 11:44
浙ICP备14020137号-1 $访客地图$