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