HTTPoison proxy option not working

I have this curl request

curl -x "http://proxy-server.com:8001" -k "https://httpbin.org/ip"

The curl request is going through the proxy server and I’m getting at each hit a new ip address (which is the expected behavior).

But when I try with HTTPoison it’s not working as expected.

I tried these codes

HTTPoison.get!("https://www.httpbin.org/ip", [], [proxy: {"http://proxy-server.com"}])

HTTPoison.get!("https://www.httpbin.org/ip", [], [{:proxy, "http://proxy-server.com"}])

What am I doing wrong ?

The proxy option expects either a binary or a two-element tuple of {host, port}, so that first one is not going to work.

As for the second one, the URL doesn’t have a port specified like the one in the curl command does. Maybe that’s the problem?

It would be useful to get more detail on “not working as expected” - what happens (error message, stack trace, etc) when you attempt those HTTPoison calls? I don’t have a proxy server handy to test with, so I can’t see what you’re seeing.

Thank you for your reply and the clear explanation.

I’ll try to tweak the code a bit more based on what you said.