I'm sorry for necro'ing this. But while searching for an answer related to a similar problem, this is where I was led to.
In my case, my client didn't support properly adding a Host header as suggested in the answers. I could use `curl` without issues, but the actual client I was using, a Classic ASP's `MSXML.ServerXMLHTTP` interface (https://learn.microsoft.com/en-us/previous-versions/windows/desktop/ms754586...)) was sending its own Host header and, when I specified mine, it sent the header twice.
I had two options:
- set an entry in etc/hosts for the host I wanted, pointing to 127.0.0.1 (where I set stunnel to listen) - use a proxy server
As it turned out, I could just use stunnel as a proxy server and it did the job!
The configuration I used in stunnel is:
[https] client = yes accept = 127.0.0.1:8445 connect = the-api.host.com:443
So, I was using my local host as the tunnel in port 8445, as client (the 'connect' endpoint implements SSL however it wants), and I wanted the host-header to have 'the-api.host.com'
Thus connecting to url=http://localhost:8445/ wouldn't do.
Then the solution in MSXML.ServerHTTP was url = http://the-api.host.com (as if port 80) proxy = http://localhost:8445/
And voila. As the client connected through the proxy it did send the host header the way I needed!
I tried not to delve too much in MSXML.ServerHTTP syntax as it is a bit off-topic, but I hope the general rules help people with similar issue with stubborn HTTP clients/libraries!