0

What's the difference between the below usage of curl?

curl -vo 1 'https://example.com' --resolve example.com:443:1.1.1.1
curl -vo 1 'https://1.1.1.1' -H 'host: example.com'   

the 1.1.1.1 presents the example.com's A address.

0

1 Answer 1

1

The first curl command-line fetches https://demo.cc with a fairly pointless --resolve option for demo.com (pointless because it's not the domain name for the URL being fetched).

The second fetches https://1.1.1.1 and sets the host: request header to demo.com.

Depending on how the server at 1.1.1.1 is configured the second curl command may fetch the default page for https://demo.com. But it probably won't - to start with, it's unlikely that Cloudflare's DNS resolver at 1.1.1.1 is configured to serve web pages for demo.com at all, and it's entirely possible that it will ignore the lowercase host: header (should be Host:, with a capital "H"), as some web servers are case-sensitive when it comes to recognising header names.


BTW, if you don't own demo.com or demo.cc then you shouldn't use them as examples, they belong to someone else. Use example.com or example.net or example.edu, or example.org instead. These domains exist solely to be used as examples and will never be assigned to anyone. See https://en.wikipedia.org/wiki/Example.com

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .