lein环服务器无头 - 只听localhost? [英] lein ring server-headless - only listen to localhost?
问题描述
我有一个使用lein-ring和compojure web框架的Clojure项目,我开始使用 lein ring server-headless
命令。它产生以下输出:
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
在端口3000上启动服务器
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
我只是意识到这是在 0.0.0.0
上侦听。 A netstat -nltp
确认:
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
tcp6 0 0 :::3000 :::* LISTEN 31781/java
可能为 lein环服务器无头
只侦听localhost?
Is it possible for lein ring server-headless
to only listen to localhost?
推荐答案
为了配置Jetty只侦听特定接口,添加:host
键插入到您的project.clj中的:ring {:handler ...}
该值应为Jetty应侦听的接口的主机名或IP地址。例如,:ring {:handler yourapp.handler / app:hostlocalhost}
仅在localhost上侦听。
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.
这篇关于lein环服务器无头 - 只听localhost?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!