45-HTTP protocol

What is 1.http

Users enter the URL into the browser process what happened
flow users to access the site

DNS解析过程,     域名对应的ip地址          
TCP/ip 三次握手, 与服务器建立链接
HTTP请求报文,    用户向服务器要东西(图片 页面)
HTTP响应报文,    把你要的内容给你
TCP/ip 四次挥手, 与服务器断开连接

16952149-6909156950c4b242.png
image

Detailed analytical process 2.DNS

16952149-16dffa6c5ada0d4f.png
image
16952149-900c6b2f389713e6.png
image

DNS name resolution process

16952149-3d9f6cfb1ab0cacc.png
image
16952149-55f1ba95a59a9872.png
image

windows local hosts file:

16952149-cbcb8d38b51dce63.png
image

The domain structure (hierarchy)

www.baidu.com.  (最后的点)
[d:\~]$ ipconfig /displaydns
    查看DNS缓存
[d:\~]$ ipconfig /display
    释放DNS缓存
[d:\~]$ ipconfig /flushdns
    清空DNS缓存

3.dig command to use

https://www.imooc.com/article/26971?block_id=tuijian_wz
DIG command is mainly used from the DNS domain name server queries the host address information
dig yum provides
query installation package
yum install -y bind-utils
mounted dig bind-utils

you www.baidu.com www.jd.com

DNS record type

you + trace www.baidu.com

记录1个对应关系
A记录
    域名 ip地址记录
CNAME记录
    别名记录
MX记录
    邮件使用

16952149-789e32e629881fa9.png
image

nslookup belongs to dig package

[10:25 root@web01 ~]# rpm -qf `which nslookup`
bind-utils-9.9.4-73.el7_6.x86_64
[10:27 root@web01 ~]# nslookup
> www.baidu.com
Server:     10.0.0.254
Address:    10.0.0.254#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 39.156.66.14
Name:   www.a.shifen.com
Address: 39.156.66.18
> 

host belongs to dig package

[10:28 root@web01 ~]# host www.baidu.com
www.baidu.com is an alias for www.a.shifen.com.
www.a.shifen.com has address 39.156.66.18
www.a.shifen.com has address 39.156.66.14

Web site set up process

云服务器
    搭建LNMP环境部署 wordpress
购买域名
    备案(网站基本性信息 个人信息 提交给信息管理局)
配置DNS解析(记录)
    记录类型
    主机记录
    记录值
    TTL  存活时间(缓存时间)

16952149-46d1e9e4d755cdaf.png
image
16952149-1c394648e70c87e0.png
image

HTTP request and response process:

16952149-dff8b0da7cb793b7.png
image
16952149-231e7b6e3ab712b1.png
image
16952149-c0ca5dcfe009fbc8.png
image

Client requests:

16952149-5a4939e55038b7d7.png
image

Server response:

16952149-5b265bb8cf6a32bb.png
image

Client request and server response process:

curl -v www.baicu.com

[11:31 root@web01 ~]# curl -v www.baidu.com/index.html
* About to connect() to www.baidu.com port 80 (#0)   \\DNS解析
*   Trying 39.156.66.14...
* Connected to www.baidu.com (39.156.66.14) port 80 (#0)   \\Tcp三次握手
> GET /index.html HTTP/1.1    \\http请求报文 ,请求起始行
> User-Agent: curl/7.29.0     \\用户的浏览器
> Host: www.baidu.com         \\请求域名
> Accept: */*   
>                           \\空行
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: Keep-Alive
< Content-Length: 2381
< Content-Type: text/html
< Date: Mon, 03 Jun 2019 03:32:03 GMT
< Etag: "588604c8-94d"
< Last-Modified: Mon, 23 Jan 2017 13:27:36 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
< 
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type 
content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible 
content=IE=Edge><meta content=always name=referrer><link rel=stylesheet 
type=text/css href=http://s1.bdstatic.com/r/www/cache/bdorz/baidu.min.css><title>
百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div 
....

16952149-63d9762f7115ec64.png
image

wget --debug www.baidu.com

[12:06 root@web01 ~]# wget --debug www.baidu.com
DEBUG output created by Wget 1.14 on linux-gnu.

URI encoding = ‘UTF-8’
Converted file name 'index.html' (UTF-8) -> 'index.html' (UTF-8)
Converted file name 'index.html' (UTF-8) -> 'index.html' (UTF-8)
--2019-06-03 12:07:08--  http://www.baidu.com/
Resolving www.baidu.com (www.baidu.com)... 39.156.66.18, 39.156.66.14
Caching www.baidu.com => 39.156.66.18 39.156.66.14
Connecting to www.baidu.com (www.baidu.com)|39.156.66.18|:80... connected.
Created socket 3.
Releasing 0x000000000138e9a0 (new refcount 1).

---request begin---
GET / HTTP/1.1
User-Agent: Wget/1.14 (linux-gnu)
Accept: */*
Host: www.baidu.com
Connection: Keep-Alive

---request end---
HTTP request sent, awaiting response... 
---response begin---
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
Connection: Keep-Alive
Content-Length: 2381
Content-Type: text/html
Date: Mon, 03 Jun 2019 04:07:07 GMT
Etag: "588604c8-94d"
Last-Modified: Mon, 23 Jan 2017 13:27:36 GMT
Pragma: no-cache
Server: bfe/1.0.8.18
Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/

---response end---
200 OK
cdm: 1 2 3 4 5 6 7 8
Stored cookie baidu.com -1 (ANY) / <permanent> <insecure> [expiry 2019-06-04 12:07:08] BDORZ 27315
Registered socket 3 for persistent reuse.
Length: 2381 (2.3K) [text/html]
Saving to: ‘index.html’

100%[========================================>] 2,381       --.-K/s   in 0s      

2019-06-03 12:07:08 (29.2 MB/s) - ‘index.html’ saved [2381/2381]

※ Wireshark packet capture

16952149-96e3f2da9b41d6a0.png
image
16952149-56ca66ba48371565.png
image

Request Process

16952149-7359ef3d2f67d808.png
image

Response process

16952149-4af98253fbbd8610.png
image

Status code meaning:

16952149-89abe270f6ebbc73.png
image
16952149-22397c9341fa791c.png
image
16952149-a29fae141a0f4a5a.png
image
16952149-91f34f84d708de2e.png
image
16952149-0265750e7e9dd145.png
image

Reproduced in: https: //www.jianshu.com/p/8d07cfdbae09

Guess you like

Origin blog.csdn.net/weixin_33670786/article/details/91264384