gpt4 book ai didi

java - 如何运行 nginx 作为 jetty 的代理?

转载 作者:行者123 更新时间:2023-12-01 13:41:38 24 4
gpt4 key购买 nike

我有这样的设置:

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

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

我正在另一台笔记本电脑 (OSX) 上编程,并使用 lein 创建了一个项目 web_test。我创建了 web_test.war 文件,当我运行 leinring server 时,我看到了 core.clj 的内容> 在浏览器上。

最初,我在 this answer 之后设置了 nginx conf 文件。但我无法让它发挥作用。

我想问如何修复下面的conf文件(带着我的问题)以及如何使用nginx作为jetty的代理来部署web_test。

我粘贴了下面的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;
}
}

注意:这是我关于同一主题的第三个问题,但我仍然无法解决。感谢您的所有帮助。

最佳答案

server 应包含上游服务器的 ip:port(jetty 是您的情况)。

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

关于java - 如何运行 nginx 作为 jetty 的代理?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20705984/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com