lein ring server-headless - only listen to localhost?

。_饼干妹妹 提交于 2019-12-10 15:16:00

问题


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 SelectChannelConnector@0.0.0.0: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:


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.



来源:https://stackoverflow.com/questions/24467539/lein-ring-server-headless-only-listen-to-localhost

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!