
Hello haskellers, I want to host a simple happstack application behind a reverse proxy. So ideally would be to bind it to localhost only. According to http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/... Conf datatyle has only Port field. Does it mean, there is currently no way to prevent binding happstack to all available interfaces? Regards, Dmitry

Hi Dmitry, On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
Hello haskellers,
I want to host a simple happstack application behind a reverse proxy. So ideally would be to bind it to localhost only.
According to http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/... Conf datatyle has only Port field. Does it mean, there is currently no way to prevent binding happstack to all available interfaces?
I think you are looking for simpleHTTPWithSocket [1]. You can use whatever socket you like.
Regards, Dmitry
Cheers, Martin [1] http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.h...

You misunderstand his question. He's trying to setup happstack behind a
reverse proxy running on the same system, so he needs to be able to bind it
only to the loopback interface (127.0.0.1), as opposed to all the interfaces
on the system (thereby making it inaccessible from the network unless
accessed through the proxy). I don't know enough about happstack to answer
his question, but I can see from the documentation you provided that there
doesn't seem to be any way to specify address to bind to as Dmitry stated in
his original e-mail.
-R. Kyle Murphy
--
Curiosity was framed, Ignorance killed the cat.
On Thu, Mar 11, 2010 at 07:39, Martin Kiefel
Hi Dmitry,
On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
Hello haskellers,
I want to host a simple happstack application behind a reverse proxy. So ideally would be to bind it to localhost only.
According to
http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/...
Conf datatyle has only Port field. Does it mean, there is currently no way to prevent binding happstack to all available interfaces?
I think you are looking for simpleHTTPWithSocket [1]. You can use whatever socket you like.
Regards, Dmitry
Cheers, Martin
[1] http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.h... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Thu, Mar 11, 2010 at 09:24:05AM -0500, Kyle Murphy wrote:
You misunderstand his question. He's trying to setup happstack behind a reverse proxy running on the same system, so he needs to be able to bind it only to the loopback interface (127.0.0.1), as opposed to all the interfaces on the system (thereby making it inaccessible from the network unless accessed through the proxy). I don't know enough about happstack to answer his question, but I can see from the documentation you provided that there doesn't seem to be any way to specify address to bind to as Dmitry stated in his original e-mail.
But I'm doing exactly that. Here is some of the code: main = do ... s <- socket AF_INET Stream defaultProtocol setSocketOption s ReuseAddr 1 h <- getHostByName "localhost" let p = toEnum $ port $ httpConf appConf bindSocket s (SockAddrInet p (hostAddress h)) listen s 10 -- start the state system control <- startSystemState' (store appConf) stateProxy -- start the http server httpTid <- forkIO $ simpleHTTPWithSocket s (httpConf appConf) ... And then my happstack server is just listening on 127.0.0.1. To access it, I'm using Apache Proxy. - Martin
-R. Kyle Murphy -- Curiosity was framed, Ignorance killed the cat.
On Thu, Mar 11, 2010 at 07:39, Martin Kiefel
wrote: Hi Dmitry,
On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
Hello haskellers,
I want to host a simple happstack application behind a reverse proxy. So ideally would be to bind it to localhost only.
According to
http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/...
Conf datatyle has only Port field. Does it mean, there is currently no way to prevent binding happstack to all available interfaces?
I think you are looking for simpleHTTPWithSocket [1]. You can use whatever socket you like.
Regards, Dmitry
Cheers, Martin
[1] http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.h... _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Ah, I see, I was looking at the example code in the Happstack documentation
you linked. Looking at the documentation of Network.Socket I can see where
it provides an option to bind on a particular address. The example given in
the Happstack docs uses bindPort to get the socket which confused me as
didn't realize you could initialize a socket using the Network.Socket
functions and just pass that instead. The example in your latest mail is
much clearer.
-R. Kyle Murphy
--
Curiosity was framed, Ignorance killed the cat.
On Thu, Mar 11, 2010 at 09:35, Martin Kiefel
You misunderstand his question. He's trying to setup happstack behind a reverse proxy running on the same system, so he needs to be able to bind it only to the loopback interface (127.0.0.1), as opposed to all the interfaces on the system (thereby making it inaccessible from the network unless accessed through the proxy). I don't know enough about happstack to answer his question, but I can see from the documentation you provided that
On Thu, Mar 11, 2010 at 09:24:05AM -0500, Kyle Murphy wrote: there
doesn't seem to be any way to specify address to bind to as Dmitry stated in his original e-mail.
But I'm doing exactly that.
Here is some of the code:
main = do
...
s <- socket AF_INET Stream defaultProtocol setSocketOption s ReuseAddr 1 h <- getHostByName "localhost" let p = toEnum $ port $ httpConf appConf bindSocket s (SockAddrInet p (hostAddress h)) listen s 10
-- start the state system control <- startSystemState' (store appConf) stateProxy
-- start the http server httpTid <- forkIO $ simpleHTTPWithSocket s (httpConf appConf)
...
And then my happstack server is just listening on 127.0.0.1.
To access it, I'm using Apache Proxy.
- Martin
-R. Kyle Murphy -- Curiosity was framed, Ignorance killed the cat.
On Thu, Mar 11, 2010 at 07:39, Martin Kiefel
wrote: Hi Dmitry,
On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
Hello haskellers,
I want to host a simple happstack application behind a reverse proxy.
So
ideally would be to bind it to localhost only.
According to
http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/...
Conf datatyle has only Port field. Does it mean, there is currently no way to prevent binding happstack to all available interfaces?
I think you are looking for simpleHTTPWithSocket [1]. You can use whatever socket you like.
Regards, Dmitry
Cheers, Martin
[1]
http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.h...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

I'd like to add a warning to this discussion. You might be affected by this issue: http://trac.haskell.org/network/ticket/11 TL;DR: It is kind of random if you bind to IPv4 or IPv6 or both. For example Windows Vista likes to bind to IPv6 only. Watch your ports and protocols! -- Gracjan

Neat! I have been wondering how to do that. It is also useful if you want to
run multiple happstack applications on the same machine, but each on a
different IP address.
It would be awesome if this was wrapped up in a more obvious way. I imagine
we would extend the Conf type so that you could optionally specify a list of
IP addresses to listen on.
Unfortunately it is very tricky to implement in a portable way because our
code can not depend on ipv6 being enabled. I just posted a message to
haskell-cafe asking for suggestions.
http://www.haskell.org/pipermail/haskell-cafe/2010-March/074585.html
- jeremy
On Thu, Mar 11, 2010 at 8:35 AM, Martin Kiefel
You misunderstand his question. He's trying to setup happstack behind a reverse proxy running on the same system, so he needs to be able to bind it only to the loopback interface (127.0.0.1), as opposed to all the interfaces on the system (thereby making it inaccessible from the network unless accessed through the proxy). I don't know enough about happstack to answer his question, but I can see from the documentation you provided that
On Thu, Mar 11, 2010 at 09:24:05AM -0500, Kyle Murphy wrote: there
doesn't seem to be any way to specify address to bind to as Dmitry stated in his original e-mail.
But I'm doing exactly that.
Here is some of the code:
main = do
...
s <- socket AF_INET Stream defaultProtocol setSocketOption s ReuseAddr 1 h <- getHostByName "localhost" let p = toEnum $ port $ httpConf appConf bindSocket s (SockAddrInet p (hostAddress h)) listen s 10
-- start the state system control <- startSystemState' (store appConf) stateProxy
-- start the http server httpTid <- forkIO $ simpleHTTPWithSocket s (httpConf appConf)
...
And then my happstack server is just listening on 127.0.0.1.
To access it, I'm using Apache Proxy.
- Martin
-R. Kyle Murphy -- Curiosity was framed, Ignorance killed the cat.
On Thu, Mar 11, 2010 at 07:39, Martin Kiefel
wrote: Hi Dmitry,
On Thu, Mar 11, 2010 at 11:38:44AM +0300, Dmitry V'yal wrote:
Hello haskellers,
I want to host a simple happstack application behind a reverse proxy.
So
ideally would be to bind it to localhost only.
According to
http://hackage.haskell.org/packages/archive/happstack-server/0.4.1/doc/html/...
Conf datatyle has only Port field. Does it mean, there is currently no way to prevent binding happstack to all available interfaces?
I think you are looking for simpleHTTPWithSocket [1]. You can use whatever socket you like.
Regards, Dmitry
Cheers, Martin
[1]
http://happstack.com/docs/0.4/happstack-server/Happstack-Server-SimpleHTTP.h...
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (5)
-
Dmitry V'yal
-
Gracjan Polak
-
Jeremy Shaw
-
Kyle Murphy
-
Martin Kiefel