简体   繁体   中英

start erlang/elixir on a defined interface ip address

I'm using elixir to make some XMLRPC queries to an host on my machine that accepts only call from 127.0.xy 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.xy .

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.

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}]]])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM