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:
- 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.
- 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.
- Server returns a responseThe server packages the processing result into an HTTP response message and sends it back to the client.
- 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:
-
HTTP is connectionless: being connectionless means each connection handles only one request; after the server processes the client's request and receives the client's reply, the connection is closed. This approach saves transmission time.
-
HTTP is media independent: this means that as long as the client and server know how to handle the data content, any type of data can be sent over HTTP, with the client and server specifying the appropriate MIME-type content type.
-
HTTP is stateless: the HTTP protocol is a stateless protocol; stateless means the protocol has no memory of transaction processing. The lack of state means that if subsequent processing needs prior information, it must be retransmitted, which can increase the amount of data transmitted per connection. On the other hand, when the server does not need previous information, its response is faster.
The following diagram shows the HTTP protocol communication flow:

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:
- The browser correctly implements HTTPS and the operating system has the correct and trusted Certificate Authorities installed;
- The Certificate Authority trusts only legitimate websites;
- The visited website provides a valid certificate, i.e., one issued by a Certificate Authority trusted by the operating system (most browsers warn about invalid certificates);
- The certificate correctly verifies the visited website (for example, when visiting https://www.runoob.com it received a certificate issued to www.runoob.com rather than another domain name);
- The encryption layer (SSL/TLS) of this protocol can effectively provide authentication and high-strength encryption.
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:
-
Encryption:
- HTTPThe data is not encrypted during transmission and can easily be intercepted and tampered with.
- HTTPSThe data transmitted is encrypted using the SSL/TLS protocol, protecting its security during transmission.
-
port:
- HTTPDefaults to port 80.
- HTTPSDefaults to port 443.
-
Safety:
- HTTPDoes not provide data encryption; lower security.
- HTTPSProvides data encryption and integrity verification; higher security.
-
Certificate:
- HTTPNo certificate required.
- HTTPSRequires an SSL certificate to enable encryption and verify the server's identity.
-
Performance:
- HTTPBecause data is not encrypted, performance is slightly higher than HTTPS.
- HTTPSBecause encryption and decryption are required, there may be some performance overhead.
-
Search Engine Optimization (SEO):
- HTTPSearch engines may downrank websites that do not use HTTPS.
- HTTPSSearch engines tend to prioritize indexing and displaying websites that use HTTPS.
-
Browser display:
- HTTPIn most modern browsers, HTTP sites are usually displayed as "Not secure".
- HTTPSThe browser displays a lock icon, indicating the site is secure.
-
Cost:
- HTTPUsually free.
- HTTPSRequires purchasing an SSL certificate, which may incur some cost.
-
Application scenarios:
- HTTPSuitable for websites that do not need to transmit sensitive information, such as news sites and blogs.
- HTTPSSuitable for websites that need to transmit sensitive information, such as online banking, online shopping, and email.