certstream-server icon indicating copy to clipboard operation
certstream-server copied to clipboard

Listen on specific interface ?

Open uggyuggy opened this issue 5 years ago • 2 comments

Hi, I see we can change the listening port with the PORT environment variable What configuration change could be used to be able to change the listening interface.. and define a specific one (like 127.0.0.1) ?

Thank's !

uggyuggy avatar Aug 14 '20 23:08 uggyuggy

Hi @uggyuggy, we currently set the port here

https://github.com/CaliDog/certstream-server/blob/59e497ebe9784163f899a415b223882d6ec3033f/lib/web.ex#L146

Which is passed into the :cowboy.start_clear function which initializes the webserver (cowboy). Tracing through things a bit (first https://ninenines.eu/docs/en/cowboy/2.5/manual/cowboy.start_clear, then https://ninenines.eu/docs/en/ranch/1.7/manual/ranch_tcp/), it looks like if you wanted to bind to a custom interface, you'd edit that line to look like this:

[{:port, get_port(), :ip, {127,0,0,1}}], 

Or something similar, replacing {127,0,0,1} with whatever your interface address is. Currently we don't have any way of configuring that via a environment variable, but PRs are always welcome!

Fitblip avatar Sep 07 '20 21:09 Fitblip

Hi @Fitblip

Thank's for the informations and directions. I tried to change as per your suggestion, but it seems to not work.

At the start the debug shows: [warn] Transport option {:port, 4000, :ip, {127, 0, 0, 1}} unknown or invalid. and this is not listening on the IP/Port. I tried with few other syntax for this line, but no luck so far... I will continue to search..

And thank's again for you work and for sharing this tool 👍

uggyuggy avatar Sep 10 '20 16:09 uggyuggy