Found an interesting article about
curl’s options for connecting to the different host. Most of the time I’d changed Host HTTP
header, and it was enough for my cases, but today I’ve realized that this solution is not acceptable
when for HTTPS resources. Here, I need to specify the host name during SSL connection negotiation,
so I can’t use HTTP headers. There is an SNI
field that allows to tell the server which
host I want to access. Curl uses URL to prepare SNI field value: for command curl https://example.com/foo SNI value is example.com and when I set Host header, it does not affect
SNI at all. To change SNI the –resolve option can be
used:
curl --resolve example.com:443:127.0.0.1 https://example.com/
The command above populates curl’s DNS cache with a custom entry for the host name example.com and
port 443 with the address 127.0.0.1. That is why curl will use specified IP address to start TCP
connection and then use example.com for SNI field.