如何使用nginx提供Clojure页面 [英] How to serve Clojure pages with nginx

查看:176
本文介绍了如何使用nginx提供Clojure页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ubuntu和ngingx设置了一个家用服务器,我可以提供静态文件。现在我想测试一些clojure文件,但我不清楚如何做到这一点。对于php,这似乎很容易,例如在本教程中,他为php添加了一个位置文件。这是我需要做的,只是指出Clojure文件在配置文件中的位置?

I set up a home server with ubuntu and ngingx and I can serve static files. Now I want to test some clojure files but I am not clear about how to do this. For php this seems very easy, for instance in this tutorial he adds a location for php files. Is that all I need to do, just indicate where Clojure files are in the config file?

我有Dmitry的 Web Development with Clojure Sotnikov和他谈到部署,但没有具体谈到nginx。

I have the Web Development with Clojure by Dmitry Sotnikov and he talks about deployment but not specifically about nginx.

你能指出正确的方向,我可以找到有关这方面的文档吗?

Can you point me in the right direction where I can find documentation about this?

推荐答案

考虑下一个设置:

nginx -> ring server (jetty)

您需要启动 c $ c>(使用 lein-ring 插件)在某些端口(例如8080)。 Nginx将监听80端口并将请求转发到8080.
下面是一个nginx配置示例:

You need to start lein ring server (using lein-ring plugin) on some port (say 8080). Nginx will listen at 80 port and forward requests to 8080. Here is a sample nginx config:

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

server {
    root <path-to-public-dir>;

    # 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|javascripts|stylesheets|swfs|system)/ {
        expires     max;
        add_header  Cache-Control public;
    }
}

更改 path-to-public-dir 到您的静态文件所在的目录( resources / public )。
Nginx将服务器静态文件(如果找到文件)并转发其他请求到环形服务器。

Change path-to-public-dir to directory where your static files reside (resources/public). Nginx will server static files (if file found) and forward other requests to ring server.

这篇关于如何使用nginx提供Clojure页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆