git clone 'https://github.com/xfeep/nginx-clojure.git'
Nginx-Clojure is a Nginx module for embedding Clojure or Java or Groovy programs, typically those Ring based handlers.
The latest release is v0.4.5, more detail changes about it can be found from Release History.
- Compatible with Ring and obviously supports those Ring based frameworks, such as Compojure etc.
- Http Services by using Clojure / Java / Groovy to write simple handlers for http services.
- Nginx Access Handler by Clojure / Java / Groovy
- Nginx Header Filter by Clojure / Java / Groovy
- NEW: Nginx Body Filter by Clojure / Java / Groovy
- Pub/Sub Among Nginx Worker Processes
- Shared Map based on shared memory & Shared Map based Ring session store
- Support Sente, see this PR
- Support Per-message Compression Extensions (PMCEs) for WebSocket
- APIs for Embedding Nginx-Clojure into a Standard Clojure/Java/Groovy App
- Server Side Websocket
- A build-in Jersey container to support java standard RESTful web services (JAX-RS 2.0)
- Tomcat 8 embedding support (so servlet 3.1/jsp/sendfile/JSR-356 websocket work within nginx!)
- Dynamic proxying by using Clojure / Java / Groovy to write a simple nginx rewrite handler to set var or return errors before proxy pass or content ring handler
- Non-blocking coroutine based socket which is Compatible with Java Socket API and works well with largely existing java library such as apache http client, mysql jdbc drivers.
With this feature one java main thread can handle thousands of connections.
- Handle multiple sockets parallel in sub coroutines, e.g. we can invoke two remote services at the same time.
- Asynchronous callback API of socket/Channel for some advanced usage
- Long Polling & Server Sent Events
- Run initialization clojure code when nginx worker starting
- Support user defined http request method
- Compatible with the Nginx lastest stable version 1.12.0. (Nginx 1.8.x, Nginx 1.6.x, 1.4.x is also ok, older version is not tested and maybe works.)
- One of benifits of Nginx is worker processes are automatically restarted by a master process if they crash
- Utilizes lazy headers and direct memory operation between Nginx and JVM to fast handle dynamic contents from Clojure or Java code.
- Utilizes Nginx zero copy file sending mechanism to fast handle static contents controlled by Clojure or Java code.
- Supports Linux x64, Linux x86 32bit, Win32, Win64 and Mac OS X. Freebsd version can also be got from Freebsd ports.
By the way it is very fast, the benchmarks can be found HERE(with wrk2).
Nginx-Clojure has already been published to https://clojars.org/ whose maven repository is
After adding clojars repository, you can reference nginx-clojure 0.4.5 , e.g.
Leiningen (clojure, no need to add clojars repository which is a default repository for Leiningen)
More Documents can be found from its web site nginx-clojure.github.io
Copyright © 2013-2017 Zhang, Yuexiang (xfeep) and released under the BSD 3-Clause license.
This program uses:
* Re-rooted ASM bytecode engineering library which is distributed under the BSD 3-Clause license
* Modified Continuations Library Written by Matthias Mann is distributed under the BSD 3-Clause license