0

I'm doing university work on the HTTP protocol and I want to explain "visually" how an HTTP connection occurs between a client and a server. To do this, I use in the Ubuntu terminal (which I have installed in VirtualBox) the command curl -v - i against an IP address, which is the IP address of the domain that I have previously obtained through the dig command.

The problem is that the answer I receive from the server is duplicated, and I don't understand why. I enclose the information I receive when executing the command. I have deleted the IP from the server to avoid being accused of spam.

enter image description here

john smith
  • 51
  • 3

1 Answers1

0

I think you missed something ...

First, don't use "-i" because you are printing two lines one the verbose line, and the other is the print out of the protocol.

When you try to access a web server you use a domain name, in the server-side, the web server checks the name of the domain and match it with a virtual server section in the configuration, and consequently answer the request.

By default, you request http content, but the webserver had a redirection to https ( is used to force use only https )

What do you see is an error because the content that is you looking for isn't in the root path of the server associated with the IP address.

So, try to make the request like this:

curl -v -k -H 'Host: ' https:///

falconmfm
  • 11
  • 1
  • Thanks for the answer. I have another question: Instead of first using the "dig" command to find out the IP of a domain name, and then using the curl command against that IP, is there any way to use the curl command in such a way that I could also see the connection it makes against the DNS server? Therefore, I could visually explain how an HTTP connection occurs without having to use two commands. The thing is that when I use curl with a domain name, I see that it translates the domain name to IP, but I would also like to see the connection it makes to the DNS servers. – john smith Aug 18 '19 at 17:36
  • The only tool that let you see all the traffic is "nmap", and it is a little more complicates because you are going to capture all the traffic. – falconmfm Aug 18 '19 at 17:55
  • Thank you. One last question. In fact, the command you have given me works correctly. But I have the following doubt: When I use the command without the 'Host' option, due to the -k option there are no problems with the SSL certificate, but the server does not give me the body. Why is that? In this case, what does the 'Host' option do to make everything work correctly? – john smith Aug 18 '19 at 18:30
  • It's part of the HTTP Protocol, check the RFC 2616 (https://tools.ietf.org/html/rfc2616 ) page 36 . The most common form of Request-URI is that used to identify a resource on an origin server or gateway. In this case the absolute path of the URI MUST be transmitted (see section 3.2.1, abs_path) as the Request-URI, and the network location of the URI (authority) MUST be transmitted in a Host header field. `GET /pub/WWW/TheProject.html HTTP/1.1 Host: www.w3.org` – falconmfm Aug 19 '19 at 17:31