haskell - Listen on specific host using warp -


when running warp application using run, listens on ip adresses.

for security reasons, want listen on localhost only, handling remote access using reverse proxy.

how need call run listen on specific host/ip?

note: question intentionally shows no research effort answered q&a-style.

the accepted answer got broken changes conduit and/or warp. warp no longer exports host constructor. don't need it, because hostpreference type supports overloadedstrings extension, can use string directly.

this example eliminates deprecation warnings switching setport , sethost.

{-# language overloadedstrings #-}  import network.wai (responselbs) import network.wai.handler.warp import network.http.types (status200) import network.http.types.header (hcontenttype)  main =     let port = 3000     putstrln $ "listening on port " ++ show port     let settings = setport port $ sethost "127.0.0.1" defaultsettings     runsettings settings app  app req = return $     responselbs status200 [(hcontenttype, "text/plain")] "hello world!" 

Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -