4
votes

I have a Clojure project using lein-ring and the compojure web framework, which I start using the lein ring server-headless command. It produces the following output:

2014-06-28 19:37:50.236:INFO:oejs.Server:jetty-7.6.8.v20121106 2014-06-28 19:37:50.315:INFO:oejs.AbstractConnector:Started [email protected]:3000 Started server on port 3000

I kind of just realized that this is listening on 0.0.0.0. A netstat -nltp confirms this:

tcp6 0 0 :::3000 :::* LISTEN 31781/java

Is it possible for lein ring server-headless to only listen to localhost?

1

1 Answers

3
votes

In order to configure Jetty to listen only on a specific interface, add the :host key into the :ring {:handler ...} map in your project.clj. The value should be the host name or the ip address of the interface on which Jetty should listen. For example, :ring {:handler yourapp.handler/app :host "localhost"} to listen on localhost only.