How to serve Clojure pages with nginx

Zeynel

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?

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?

edbond

Consider next setup:

nginx -> ring server (jetty)

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

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.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to serve pages from another domain using Nginx

How to serve static pages

How to serve static html pages with Rails?

docker, nginx, django and how to serve static files

How can I serve nested projects in Nginx

nginx: how to serve /index.php of subfolders?

nginx: how to serve file from a subfolder of root?

How to serve Flask static files using Nginx?

How to serve multiple web servers using nginx?

nginx reverse proxy - how to serve multiple apps

Dockerized Nginx and Django, how to serve static files

How to configure Nginx to serve https only

How to serve the static content in nginx + django + kubernetes?

How to serve media file using Nginx and django?

How can you serve a folder of files with Nginx?

How to cofigure nginx to serve a pdf file?

How to configure Apache to serve pages in a shared folder from host machine?

how to serve my own gitbook using github pages

How to serve static files for all pages, not just a few

How to serve both dynamic and static pages with Dart and shelf?

How do I serve static pages from outside of my project?

My nginx + php-fm webserver is able to serve web pages that have permission 000. Why?

How can I serve a particular file for root url in Nginx?

How to serve flask app through nginx using gunicorn on a custom domain?

How to configure nginx to serve HTML files for viewing instead of downloading?

How to serve file under root path using Nginx?

How to serve static html from arbitrary url path in nginx?

How can I configure nginx to serve a Django app and a Wordpress site?

How do I serve static files case-insensitively with nginx?