start erlang/elixir on a defined interface ip address

220 Views Asked by At

I'm using elixir to make some XMLRPC queries to an host on my machine that accepts only call from 127.0.x.y where x and y can be configurable but the ip can not be 127.0.0.1.

Simple curl requests to this host would fail unless I add the flag --interface 127.0.x.y.

How can I start my elixir application with a given interface ip different from 127.0.0.1?

The library I use to send the request is HTTPoison if this can be helpful.

1

There are 1 best solutions below

0
On BEST ANSWER

You can pass ip in the connect_options to hackney. hackney passes connect_options directly to gen_tcp, which accepts an ip:

HTTPoison.get("http://...", [], [hackney: [connect_options: [ip: {127, 0, 0, 1}]]])