Java 如何将nginx作为jetty的代理运行?

Java 如何将nginx作为jetty的代理运行?,java,nginx,clojure,proxy,jetty,Java,Nginx,Clojure,Proxy,Jetty,我有以下设置: 我将nginx和Jetty安装在一台ubuntu机器上,我使用它作为服务器。我测试了Jetty,它在0.0.0.0:8080上运行,我看到Jetty欢迎页面 我将使用的域是nomilkfor.me。nginx conf文件位于/etc/nginx/sites available/nomilkfor.me.conf中 我正在另一台笔记本电脑(OSX)上编程,我与lein创建了一个项目web\u test。我创建了一个web_test的.war文件,当我运行lein-ring ser

我有以下设置:

我将nginx和Jetty安装在一台ubuntu机器上,我使用它作为服务器。我测试了Jetty,它在0.0.0.0:8080上运行,我看到Jetty欢迎页面

我将使用的域是nomilkfor.me。nginx conf文件位于
/etc/nginx/sites available/nomilkfor.me.conf

我正在另一台笔记本电脑(OSX)上编程,我与lein创建了一个项目
web\u test
。我创建了一个
web_test
.war
文件,当我运行
lein-ring server
时,我在浏览器上看到
core.clj
的内容

最初,我在之后设置了nginx conf文件,但无法使其正常工作

我想问一下如何修复下面的conf文件(以及我的问题),以及如何使用nginx作为jetty的代理部署web_测试

我在下面粘贴了conf文件,并为每个指令添加了我的问题:

# what should the ip address and port be?
# i assume this instructs nginx to send request it receives on port 80 to Jetty server
upstream ring {
    server ????? fail_timeout=0;
}

# what directory do I need to enter here?
# do I use the clojure project root?
# do I use ~/web_test/src ?
server {
    root /?????;

    # make site accessible from http://localhost
    server_name nomilkfor.me;

    location / {
        # first attempt to serve request as file
        try_files $uri $uri/ @ring;
    }

    # we will need to understand these settings
    location @ring {
        proxy_redirect off;
        proxy_buffering off;
        proxy_set_header Host $http_host;

        # what do I use here???
        # is http://ring; correct???
        proxy_pass http://ring;
    }

    location ~ ^(assets|images|javascript|stylesheets|system)/ {
        expires    max;
        add_header Cache-Control public;
    }
}
注意:这是我关于同一主题的第三个问题,但我仍然无法解决。谢谢你的帮助


服务器
应包含ip:上游服务器的端口(jetty是您的情况)


root
是静态文件所在的web根文件夹。Nginx将在那里查找文件。这样的文件夹通常命名为“public”,因为它可以从外部访问。例如,
/js/bootstrap.min.js
请求将使nginx搜索
public/js/bootstrap.min.js
(请参阅
try_files
指令)。如果找不到这样的文件,请求将转发到jetty服务器。

谢谢,我会试试。但现在我有另一个问题,Jetty不适合我。我已经在这里和《超级用户》中问了几个关于jetty的问题。我甚至不能移除它。你能推荐另一台我可以代替jetty使用的服务器吗?我研究了树脂,但它似乎不适合初学者。有没有更容易使用的服务器我可以试试?