This chapter focuses on Web servers that work with HTTP
One, with a single virtual host to achieve multiple domain names
Based on the function of virtual host, you can use only one physical machine to achieve multiple domain name website deployment.
On the Internet, domain names can be mapped to specific IP addresses through the DNS. Multiple domain names can be mapped to the same IP address, but one domain name can be mapped to only one IP address. If the server wants to know which domain the request came from, it can get it from the Host header field in the request header.
Proxy, gateway, and tunnel
HTTP communication, in addition to the server and client, there are some applications for communication data forwarding processing, such as proxies, gateways, and tunnels, which can work with the server.
- A proxy is a forwarding application that acts as an intermediary between the server and the client. The proxy receives the client’s request and forwards it to the server, and then receives the server’s response and forwards it to the client.
- A gateway is a server that forwards communication data from other servers, and when it receives a request from a client, it processes the request as if it were a source server with its own resources.
- A tunnel is an application that mediates and maintains a connection between remote clients and servers.
2.1 the agent
The basic behavior of a proxy server is to forward requests and responses between the client and the server. The proxy does not change the request URI and sends it directly to the server that holds the resource (called the source server).
Each time a request or response is forwarded through a proxy, the Via header field is appended, which marks the proxy host information passing through it.
Reasons for using proxy servers include the use of caching techniques to reduce network bandwidth traffic, access control within an organization for specific web sites, access logs, and so on.
The use of proxies can be classified according to whether caching is used and whether messages are modified.
Caching proxy: When forwarding a response, the proxy stores the resource on the proxy server. When receiving the same resource request, the proxy returns the previously cached resource.
Transparent proxy: The type of proxy that does not modify the packet when forwarding a request or response is transparent; otherwise, it is an opaque proxy.
2.2 the gateway
A gateway works much like a proxy, but enables a server on a communication line to provide non-HTTP services.
Using gateways improves the security of communication because the communication line between the client and gateway can be encrypted to ensure the connection is secure.
2.4 the tunnel
A tunnel can establish a communication line with other servers as required and use encryption methods such as SSL to communicate. The purpose of the tunnel is to ensure secure communication between the client and the server.
Third, save the cache of resources
The cache is a copy of resources stored on the local disk of the proxy server or client.
Using caching reduces access to the source server and reduces traffic and communication time.
Cache servers are a type of proxy server and are grouped under the cache proxy type.
3.1 Validity period of cache
Even if a cache exists, the validity of the resource is confirmed to the source server due to factors such as client requirements and cache validity. If the cache fails, the cache server will fetch “new” resources from the source server again.
3.2 Client Cache
In addition to caching within the proxy server, the browser on the client side can also cache. The same client determines the validity of the resource to the source server and then returns the valid resource.