This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

I would like to send HTTPS requests to the same host but I would like to choose the target IP every time.

For example "dig digitalocean.com" shows these IPs:

digitalocean.com. 300 IN A 104.16.110.208
digitalocean.com. 300 IN A 104.16.112.208
digitalocean.com. 300 IN A 104.16.109.208
digitalocean.com. 300 IN A 104.16.113.208
digitalocean.com. 300 IN A 104.16.111.208

I don't know if this is possible without allowing insecure https (I needed to use --insecure to make this request withcurl as well), but this works: HTTPoison.get("https://104.16.110.208/", [{"host", "www.digitalocean.com"}], hackney: [:insecure]).
– DogbertApr 16 at 17:05

@Dogbert thx, it makes sense. But I have copied your exact HTTPoison line and for me it doesn't work. Can you tell me the version it ran for you?
– Barna KovacsApr 17 at 8:13

I have found how to achieve it with curl https:// DOMAIN.TLD --resolve 'DOMAIN.TLD:443:IP_ADDRESS'. But I can't figure it out how to do it per request in Erlang/Elixir.
– Barna KovacsApr 17 at 11:52

Could you put that in the question? I have (almost, but HTTPotion as elixir lib) the same question… basically sth like “I'm looking for an equivalent of curl's --resolve option”
– Patrick J. S.Jun 13 at 14:12

Try adding ssl_options in hackney with server_name_indication set to www.digitalocean.com. See erlang.org/doc/man/ssl.html. The thing is if you don't give a SNI name then it will be used from the host name/IP you used while connecting to the server
– Tarun LalwaniJun 13 at 18:06

That almost works. I had to use single quotes for the ssl_option (it said something the error above, which makes sense, since it is an erlang lib, there should be “erlang quotes”). Also, I think the formatting could be impoved. get(…, hackney: [ssl_options: [server_name_indication: 'digitalocean.com]])' worked for me.
– Patrick J. S.Jun 18 at 22:45

@PatrickJ.S., thanks for the feedback. Updated the answer with the same
– Tarun LalwaniJun 19 at 12:12