gpt4 book ai didi

nginx - 我可以将 Clojure 与 nginx 一起使用吗?

转载 作者:行者123 更新时间:2023-12-03 06:56:02 25 4
gpt4 key购买 nike

这是我的问题 here 的后续问题。我已经设置了一个家庭服务器(只是我的另一台笔记本电脑运行 ubuntu 和 nginx),并且我想提供 clojure 文件。

我请求帮助以了解此过程的工作原理。很抱歉,此时我很困惑,我想我需要重新开始。我问一个新问题,因为我想使用 nginx 而不是 lein 环服务器,如该问题的答案中所建议的。

首先,我与 leiningen 启动了一个项目 guestbook,并运行了 lein 环服务器,我在 localhost:3000 处看到“Hello World”。据我了解这与nginx无关!

nginx是如何进入这个进程的?起初,我尝试使用 nginx 创建代理服务器,这也有效,但我不知道如何使用该设置提供 clojure 文件。

这是我的 nginx.conf 文件中的内容,改编自 this answer :

 upstream ring {
server 127.0.0.1:3000 fail_timeout=0;
}

server {
root /home/a/guestbook/resources/public;

# make site accessible from http://localhost
server_name localhost;

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

location @ring {
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $http_host;
proxy_pass http://ring;
}

location ~ ^(assets|images|javascript|stylesheets|system)/ {
expires max;
add_header Cache-Control public;
}
}

所以我想使用我的域名 example.com (不是 localhost);我该怎么做?

<小时/>

编辑

根据 @noisesmith's comment我会选择 lein uberjar 选项。正如所解释的here ,看起来很容易创建一个:

$ lein uberjar
Unpacking clojure-1.1.0-alpha-20091113.120145-2.jar
Unpacking clojure-contrib-1.0-20091114.050149-13.jar
Compiling helloworld
[jar] Building jar: helloworld.jar
$ java -jar helloworld.jar
Hello world!

您还能指导我找到有关如何将这个 uberjar 与 nginx 一起使用的正确文档吗?

最佳答案

请尝试Nginx-Clojure module 。您可以使用 Nginx 运行 clojure Ring 处理程序,而无需任何 Java Web 服务器,例如。码头。

关于nginx - 我可以将 Clojure 与 nginx 一起使用吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20666497/

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