Restricting Jetty to listen to localhost

168 views
Skip to first unread message

Dave Gurnell

unread,
Jul 28, 2010, 9:29:41 AM7/28/10
to simple-build-tool
Dear all,

I'm new to SBT and Jetty so apologies if this is a stupid question.
Can I get the "sbt jetty-xxxxx" commands to configure Jetty so it only
listens to connections from localhost?

I'm deploying an application on a customer's server, using an in-house
single-sign-on service that's only available as an Apache module. I've
set everything up so Apache forwards the relevant authentication
details as HTTP headers, but I need to restrict Jetty to only listen
to localhost to properly secure the application.

I've been mooching around in the source code and I've come up with a
starting point (attached). The good news is that Jetty is running on
the correct port with the correct IP restrictions. The bad news is
that I have no app. I'm guessing I'll have to write a complete Jetty
configuration to get things to work. I've not idea yet what this might
entail.

Am I going about this the right way, or is there a better way to do
things?

Many thanks in advance,

-- Dave

--------------------------------------------------

import sbt._

class MyProject(info: ProjectInfo) extends DefaultWebProject(info) {

val jetty = "org.eclipse.jetty" % "jetty-webapp" % "7.0.2.v20100331"
% "test"

// ...

override lazy val jettyInstance = new
JettyRunner(customJettyConfiguration)

def customJettyConfiguration = {
val myLog = log
val myJettyClasspath = jettyClasspath

new CustomJettyConfiguration {
def war = jettyWebappPath
def scanDirectories = Nil
def scanInterval = 0
def jettyClasspath = myJettyClasspath
def classpath = jettyRunClasspath
def classpathName = "test"
def log = myLog
override def jettyConfigurationXML =
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<Call name="addConnector">
<Arg>
<New
class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="port">8765</Set>
<Set name="host">localhost</Set>
</New>
</Arg>
</Call>
</Configure>
}
}

}

Mark Harrah

unread,
Jul 29, 2010, 8:04:05 PM7/29/10
to simple-b...@googlegroups.com
Hi Dave,

You probably want to 'package' your web application as a war and deploy it with Jetty independent of sbt.

-Mark

Dave Gurnell

unread,
Jul 30, 2010, 5:17:27 AM7/30/10
to simple-b...@googlegroups.com
Hi Mark,

Thanks for your reply. I figured out how to install the standalone server last night, so I'm up and running properly now.

I'm still on the steep part of the learning curve, but I'm getting there.

Best regards,

-- Dave

> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To post to this group, send email to simple-b...@googlegroups.com.
> To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
>

Reply all
Reply to author
Forward
0 new messages