binding to 127.0.0.1 (instead of localhost or 0.0.0.0)

78 views
Skip to first unread message

Andy L

unread,
Mar 20, 2019, 10:59:16 PM3/20/19
to Ring
Hi,

I have been a happy use or compojure{,-api} and ring for a while for my rather high level apps. All works remarkably well and I am super grateful for those libraries.

Now, I run into a specific need, as in subject to have my services being hidden behind nginx and not exposing the port outside of 127.0.0.1. Based on my research, while it is probably possible to overwrite default host via Jetty proprieties, I would like to achieve the same via lein/ring options.


It seems though, that there is not possible to pass :host option with my desired 127.0.0.1.

I have 3 questions:

 1- how lein (or rather lein-ring) inject a jetty dependency . Jetty is not shown under "lein deps :tree".
 3- what would be insights to pass :host to jetty itslef, other than explicit call like in https://github.com/ring-clojure/ring/wiki/Getting-Started

I would appreciate your help,
Best regards,
Andy

PS. I completed homework of trying to find answers for above online to no avail in spite of a few hours of research.

James Reeves

unread,
Mar 20, 2019, 11:11:45 PM3/20/19
to Ring
Have you tried adding the following option to your project.clj file:

    :ring {:adapter {:host "127.0.0.1"}}

In answer to your other questions:

1. Lein-Ring uses Leiningen's eval-in-project function to start the Ring server, which can be given additional dependencies.
2. That builds the form that eval-in-project executes.
3. Use the :adapter option to pass in whatever options you require to the Jetty adapter.

--
You received this message because you are subscribed to the Google Groups "Ring" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-clojure...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
James Reeves

Andy L

unread,
Mar 23, 2019, 4:39:11 PM3/23/19
to Ring
James,

Thanks for the solution and explanations. I wonder how we could express `:adater` key in the documentation though - I can submit PR if needed.

Best regards,
Andy

James Reeves

unread,
Mar 23, 2019, 6:32:29 PM3/23/19
to Ring
The :adapter key is described in the README, but adding a link to the Jetty adapter options would probably be a good idea.

--
You received this message because you are subscribed to the Google Groups "Ring" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-clojure...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
James Reeves
Reply all
Reply to author
Forward
0 new messages