If you use Global Accelerator for your HTTPS service, you can enable HTTP/2 for connections to your backend services. This allows you to use HTTP/2 features to improve performance, reduce latency, and lower network overhead.
What is HTTP/2
HTTP/2 negotiation
For HTTPS connections, the client and server must establish a Transport Layer Security (TLS) connection before sending application data. To support HTTP/2, the handshake uses Application-Layer Protocol Negotiation (ALPN) to determine which protocol version to use.
When you enable HTTP/2 in Global Accelerator, it specifies h2 in the ALPN field of the ClientHello message during the TLS handshake. Global Accelerator then ignores the protocol version returned by the server in the ServerHello message, forcing an HTTP/2 connection to the backend service.
Use case
This topic uses the following scenario. A company is headquartered in the US (Silicon Valley) and hosts its HTTPS website on Alibaba Cloud ECS instances. Most of its clients are located in China (Hong Kong). The company uses Global Accelerator to mitigate network issues such as latency, jitter, and packet loss caused by unstable cross-border public networks.
To further improve website performance and user experience, the company plans to adopt the HTTP/2 protocol.
By default, when Global Accelerator is configured with HTTPS as the backend service protocol, it connects to backend services using HTTP/1.1. The company now needs to modify its Global Accelerator instance configuration to specify HTTP/2 for backend connections to take full advantage of the protocol's performance improvements.
Limitations
The following limitations apply when you configure Global Accelerator to use HTTP/2 to connect to backend services:
-
If the Protocol Version option is not available for your Global Accelerator instance, your instance may not support this feature. To enable it, contact your account manager to upgrade your instance.
-
The WebSocket protocol is not supported.
-
The Server Push feature of HTTP/2 is not supported.
-
gRPC requests that are based on HTTP/2 cannot be accelerated.
Prerequisites
-
Purchase or upload a server certificate in the Certificate Management Service console. For more information, see Purchase an official certificate and Upload, sync, and share SSL certificates.
-
Upload the certificate files to your backend server. For more information, see Use Cloud Assistant to upload a file to an ECS instance.
-
Your backend server has an HTTPS service deployed on port 443 with the HTTP/2 protocol version enabled.
Make sure you have added a rule to allow inbound traffic on TCP port 443 in the backend server's security group. For more information, see Add a security group rule.
-
Create a Global Accelerator instance, add the backend server as an endpoint, and set the backend service protocol to HTTPS. For more information, see Create and manage standard Global Accelerator instances.
-
Ensure your domain is mapped to the CNAME address assigned by the Global Accelerator instance. For more information, see Add a CNAME record.
Configure HTTP/2 for backend connections
This section describes only the key configuration items relevant to this scenario. For more information about endpoint group settings, see Add and manage endpoint groups for intelligent-routing listeners.
Log on to the GA console.
-
On the Instances page, find the GA instance that you want to manage and click Configure Listener in the Actions column.
-
On the Listeners tab, find the target listener, and then click Modify Endpoint Group in the Actions column.
-
In the Configure Listener & Protocol step of the wizard, click Next.
-
In the Configure Endpoint Group step of the wizard, set IP Version to HTTP/2, and then click Next.
Set Backend Service Protocol to HTTPS and Protocol Version to HTTP/2.
-
In the Configuration Review step, confirm the configuration and click Submit.
Verify the results
To verify that HTTP/2 is enabled, perform the following steps before and after you change the protocol version.
-
From a client in the China (Hong Kong) region, open a browser and enter
https://<accelerated domain name>. You should be able to access the backend service normally. -
On the backend server in the US (Silicon Valley) region, open a command-line window and run the following command to view the most recent access record.
The access record shows the protocol version used to forward the request to the backend server.
tail -n 1 /var/log/nginx/access.logBefore you configure the protocol version, the access log shows that the back-to-origin request uses the
HTTP/1.1protocol.[root@iZxxx ~]# tail -n 1 /var/log/nginx/access.log 172.20.xxx - - [30/Jul/2024:14:40:40 +0800] "GET / HTTP/1.1" 200 27 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0 Safari/537.36 Edg/126.0.0.0" "47.76.xxx"After you configure the protocol version to HTTP/2, the access log shows that the back-to-origin request uses HTTP/2.0.
[root@iZrj95wxxx xxx ~]# tail -n 1 /var/log/nginx/access.log 172.20.xxx.xxx - - [30/Jul/2024:14:42:55 +0800] "GET / HTTP/2.0" 200 27 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0 Safari/537.36 Edg/126.0.0" "47.76.xxx.xxx"
Related documents
Tutorials
-
For detailed information about endpoint group settings, see Add and manage endpoint groups for intelligent-routing listeners.
-
To upgrade client-facing connections to HTTP/3, set the maximum HTTP version for client-to-Global-Accelerator access to HTTP/3. For more information, see Use HTTP/3 to improve the access experience of your applications.
API reference
-
CreateEndpointGroup: Creates an endpoint group. Use the
EndpointProtocolVersionparameter to specify the protocol version for connecting to backend services. -
UpdateEndpointGroup: Modifies the business configuration of an endpoint group. Use the
EndpointProtocolVersionparameter to specify the protocol version for connecting to backend services. -
DeleteEndpointGroup: Deletes an endpoint group.