A browser and a web server talk HTTP: connect, ask for a page, get an answer. curl does the same from the terminal.
New command
curl
Asks for a web page and prints it. -v shows the whole conversation: * what curl did, > what it sent, < what came back.
Usagecurl url
text
learner@ops:~$ curl -v http://web/
…
* Connected to web (10.0.0.10) port 80 ← connected
> GET / HTTP/1.1 ← the request: give me /
> Host: web
…
< HTTP/1.1 200 OK ← the status: here it is
< Server: nginx/1.24.0 (Ubuntu) ← headers: about the answer
…
<
<!doctype html> ← the body: the page itself
…The Server header names the program that answered. On web, nginx takes requests on port 80 and passes most of them to the shop app on port 8080, then sends the app's answer back. Ask port 8080 directly, and the app answers itself.
Objectives
- Which program answers on port 80?
- Which program answers on port 8080?