Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTTP/HTTPS Introduction

HTTP/HTTPS Introduction

**HTTP (Hypertext Transfer Protocol)** is a transfer protocol used to transmit hypertext from the network to a local browser. It defines the format of requests and responses between client and server. HTTP works on top of the TCP/IP model and typically uses port 80.

**HTTPS (Hypertext Transfer Protocol Secure)** is the secure version of HTTP. It adds the SSL/TLS protocol under HTTP, providing data encryption, integrity verification, and authentication. HTTPS typically uses port 443.

HTTP

HTTP stands for Hyper Text Transfer Protocol, the transfer protocol used to transmit hypertext from a World Wide Web (WWW: World Wide Web) server to a local browser.

HTTP is a communication protocol based on TCP/IP for transmitting data (HTML files, image files, query results, etc.).

HTTPS

HTTPS stands for HyperText Transfer Protocol Secure, a transfer protocol for secure communication over a computer network.

HTTP itself is insecure because the transmitted data is unencrypted and may be eavesdropped on or tampered with. To solve this problem, HTTPS was introduced, which adds the SSL/TLS protocol on top of HTTP, providing encryption and authentication for data transmission.

HTTPS communicates via HTTP but uses SSL/TLS to encrypt data packets. The main purpose of developing HTTPS is to provide authentication of the website server and protect the privacy and integrity of exchanged data.

An HTTP URL starts with http:// and uses the default port 80, while an HTTPS URL starts with https:// and uses the default port443.


How HTTP works

The HTTP protocol works on a client-server architecture.

The HTTP working process is usually as follows:

  1. Client initiates a requestThe user enters a URL through a client (such as a browser), and the client sends an HTTP request to the server.
  2. Server processes the requestAfter receiving the request, the server processes it according to the request type (such as GET, POST, etc.) and the requested resource.
  3. Server returns a responseThe server packages the processing result into an HTTP response message and sends it back to the client.
  4. Client renders the pageAfter receiving the response, the client renders the page based on the response content (such as HTML, images, etc.) and displays it to the user.

Web servers include: Nginx, Apache, IIS (Internet Information Services), and so on.

The default HTTP port is 80, but you can change it to 8080 or another port.

Three notes about HTTP:

The following diagram shows the HTTP protocol communication flow:

cgiarch


The role of HTTPS

The main role of HTTPS is to create a secure channel over an insecure network, and to provide reasonable protection against eavesdropping and man-in-the-middle attacks when appropriate cipher suites are used and the server certificate can be verified and trusted.

HTTPS trust is based on Certificate Authorities (CAs) pre-installed in the operating system.

Therefore, an HTTPS connection with a website can only be trusted under these conditions:

Browsers such as Google Chrome, Internet Explorer, and Firefox warn when a site contains mixed content made up of both encrypted and unencrypted content.

An HTTP link is shown as not secure:

An HTTPS link is shown as secure:


Differences between HTTP and HTTPS

Although HTTP and HTTPS are very similar in name, they have essential differences in security: HTTPS uses the SSL/TLS protocol to provide encryption and integrity verification for data transmission, thereby protecting users' privacy and data security. As awareness of network security grows, more and more websites are using HTTPS to protect user data.

At the same time, mainstream browsers and search engines are also encouraging websites to use HTTPS.

Therefore, for websites that transmit sensitive information, it is recommended to use HTTPS to improve security.

The main differences are as follows:

- **HTTP**: The data is not encrypted during transmission and can easily be intercepted and tampered with. - **HTTPS**: The data transmitted is encrypted using the SSL/TLS protocol, protecting its security during transmission. - **HTTP**: Defaults to port 80. - **HTTPS**: Defaults to port 443. - **HTTP**: Does not provide data encryption; lower security. - **HTTPS**: Provides data encryption and integrity verification; higher security. - **HTTP**: No certificate required. - **HTTPS**: Requires an SSL certificate to enable encryption and verify the server's identity. - **HTTP**: Because data is not encrypted, performance is slightly higher than HTTPS. - **HTTPS**: Because encryption and decryption are required, there may be some performance overhead. - **HTTP**: Search engines may downrank websites that do not use HTTPS. - **HTTPS**: Search engines tend to prioritize indexing and displaying websites that use HTTPS. - **HTTP**: In most modern browsers, HTTP sites are usually displayed as "Not secure". - **HTTPS**: The browser displays a lock icon, indicating the site is secure. - **HTTP**: Usually free. - **HTTPS**: Requires purchasing an SSL certificate, which may incur some cost. - **HTTP**: Suitable for websites that do not need to transmit sensitive information, such as news sites and blogs. - **HTTPS**: Suitable for websites that need to transmit sensitive information, such as online banking, online shopping, and email.

More reference material