Embeding Nginx-Clojure into a standard java/clojure app without additional Nginx process. It can make test/debug with nginx-clojure clojure/java handler quite easy.

Jar Repository

For Clojure

[nginx-clojure/nginx-clojure-embed "0.4.3"]

For Java (Maven)


Start/Stop Embedded Server

For Clojure

    ;;(1) Start it with ring handler and an options map
    ;;my-app can be a simple ring hanler or a compojure router.
    (run-server my-app {:port 8080})

   ;;(2) Start it with a nginx.conf file
    (run-server "/my-dir/nginx.conf")

   ;;(3) Start it with a given work dir
    (binding [*nginx-work-dir* my-work-dir]
      (run-server ...))

   ;;(4) Stop the server

For Java

//Start it with ring handler and an options map
NginxEmbedServer.getServer().start("my.HelloHandler", ArrayMap.create("port", "8081"));

//Start it with with a nginx.conf file

//Start it with a given work dir

//Stop the server

Default Options

          "error-log", "logs/error.log",
          "max-connections", "1024",
          "access-log", "off",
          "keepalive-timeout", "65",
          "max-threads", "8",
          "host", "",
          "port", "8080",

User defined zones

          ;;;at nginx.conf top level
          "global-user-defined", "",

          ;;;at nginx.conf http block
          "http-user-defined", "",

          ;;at nginx.conf types mapping block
          "types-user-defined", "",

          ;;at nginx.conf server block
          "server-user-defined", "",

          ;;at nginx.conf location block
          "location-user-defined", ""