From QUIC to HTTP2: Building a more stealthy and stable Cloudflare Tunnel solution
本文最后更新于 314 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
Article Abstract
Cloudflare Tunnel defaults to the QUIC protocol to achieve advantages such as low latency, packet loss resistance, and connection migration. However, in abnormal network environments, QUIC's UDP/443-based characteristics make it easy to be identified and blocked, leading to unstable connections. To address this issue, switching to the HTTP/2 protocol can leverage its TCP/443-based stealthiness to evade network interference and improve availability. Practice shows that HTTP/2 performs more stably in long-connection scenarios (such as gRPC), ensuring transmission continuity through TCP's reliability mechanisms and multiplexing features. The article also provides configuration methods for Debian, Docker, and Win/Mac platforms, emphasizing the key role of enabling HTTP/2 in complex network environments for connection stability and stealthiness, especially suitable for scenarios with strict network restrictions like mainland China.
Qwen3-14B · 2026-06-18

Preface

Last week, because I went back to my hometown to celebrate the New Year early and stayed for a few days, I didn't have much time to write articles (actually, there are 2 articles in progress, but both are stuck in the middle and need time for research and experimentation). Therefore, this week's content can be a short but necessary standalone article to highlight a key point of knowledge: the 2 communication protocols of Cloudflare Tunnel.”QUIC (Default) 和 HTTP/2“.

Introduction to Cloudflare Tunnel Communication Protocols

QUIC Protocol

(1) Introduction

QUIC (Quick UDP Internet Connections) is a protocol developed by Google and subsequently standardized by the IETF, based on UDP built to improve the transmission efficiency of modern networks.

(2) Features

• Low-latency connection: Supports 0-RTT and 1-RTT handshakes, establishing connections extremely fast.

• Integrated encryption: QUIC natively integrates TLS 1.3, encrypting every transmission to enhance security.

• Multiplexing: Each stream is independent and unaffected by other streams, solving the “head-of-line blocking” problem in TCP.

• Efficient handling of packet loss: QUIC only retransmits lost packets without affecting other streams.

• Connection migration: QUIC can maintain connections during IP or network switches (such as switching from Wi-Fi to mobile networks).

(3) Advantages

• Faster performance: Performs exceptionally well, especially in high-latency and high-packet-loss environments.

• More flexible adaptation: Suitable for dynamic and complex network conditions.

HTTP/2 Protocol

(1) Introduction

HTTP/2 is based on TCP protocol, an improved version of HTTP/1.1, focusing on optimizing Web performance.

(2) Features

• Multiplexing: Supports multiple requests and responses sharing a single TCP connection.

• Header compression: Reduces the size of requests and responses.

• Priority control: Supports assigning higher priority to important resources.

(3) Limitations

• Head-of-line blocking: Because HTTP/2 relies on TCP, once a single packet is lost, the entire TCP connection is blocked.

• Slow connection establishment: TCP requires a three-way handshake, plus a TLS handshake, making the initial connection take longer.

• Poor connection migration: Unable to maintain the connection when IP or network changes like QUIC does.

Reasons Why Cloudflare Tunnel Defaults to QUIC

Cloudflare Tunnel chose QUIC as its default communication protocol instead of HTTP/2, mainly based on the following reasons:

Fast connection establishment

QUIC supports 0-RTT or 1-RTT handshakes, which significantly reduces latency and improves user experience compared to HTTP/2's multi-stage TCP+TLS handshake.

Better packet loss resistance

QUIC avoids head-of-line blocking through stream-level packet loss recovery, whereas HTTP/2 relies on TCP, where packet loss blocks the entire connection, leading to degraded performance.

Adaptability to dynamic environments

QUIC's connection migration capability allows clients to maintain connections during IP or network switches, making it suitable for modern mobile and multi-network environments.

Integrated security

QUIC natively supports TLS 1.3, offering higher security and lower encryption overhead, simplifying the combination of the transport layer and the security layer.

Meets high-performance requirements

Cloudflare Tunnel needs to provide users with high-throughput, low-latency, and highly reliable connections, and QUIC outperforms HTTP/2 in these aspects.

Summary

• QUIC is the default protocol for Cloudflare Tunnel because of its advantages in fast connection, efficient packet loss handling, dynamic adaptability, and higher security.

• HTTP/2 Although it also supports multiplexing and header compression, limitations based on TCP make its performance inferior to QUIC in highly dynamic and complex network environments.

From the above description, it can be seen that in normal network environments, it is very wise for Cloudflare Tunnel to default to QUIC as the communication protocol. However, what about in abnormal network environments?

Advantages of HTTP/2

In abnormal network environments, the prominent characteristics of QUIC (based on UDP/443) may make it easy to be interfered with or even blocked, while HTTP/2 is based on TCP/443, offering stronger traffic stealthiness and making it more suitable for dealing with strict network restrictions. Therefore, using HTTP/2 in these scenarios with Cloudflare Tunnel can significantly improve connection stealthiness and availability, making it a reliable choice in complex network environments.

Limitations of QUIC in Abnormal Network Environments

  1. QUIC is easy to identify and interfere with

• QUIC is based on UDP/443, rather than traditional TCP/443. This makes its traffic pattern significantly different from traditional HTTPS traffic, making it easy to be identified by DPI (Deep Packet Inspection) devices.

• Some operators or firewalls may restrict UDP traffic, or rate-limit or even block QUIC traffic, leading to unstable transmission.

  1. Low penetration rate of UDP traffic

• Although the UDP protocol is technically excellent, it is not as universally used as TCP in actual deployment. This makes QUIC traffic more conspicuous and easily flagged as abnormal in closed environments.

  1. Limited availability of QUIC

• If UDP/443 is blocked, QUIC cannot function properly, which may lead to connection interruption.

Stealthiness Advantages of HTTP/2

In the above environments, HTTP/2, as a protocol based on TCP/443, can well conceal traffic characteristics and improve availability:

Stealthiness based on TCP/443

• HTTP/2 uses TCP/443, which is the standard port for HTTPS, and its traffic pattern is almost identical to traditional HTTPS traffic.

• Deep packet inspection devices find it harder to distinguish between HTTP/2 and ordinary HTTPS traffic, which effectively reduces the risk of identification and interference.

High compatibility

• TCP is the mainstream protocol for network communication, and its traffic has high availability and pass-through rates globally.

• HTTP/2 can work normally in any network environment that supports HTTPS, without being restricted by specific network policies.

Resistance to interference

• Even if there is jitter, rate limiting, or packet loss in the network, TCP's reliability mechanism ensures data integrity, guaranteeing a stable connection.

• Compared to QUIC, which may fail completely due to UDP restrictions, HTTP/2's transmission is more robust.

Deployment maturity

• HTTP/2 relies on years of TCP technology accumulation, and its deployment and tuning are more mature globally, making it suitable for use in complex network environments.

So, in abnormal network environments, using HTTP/2 as the communication protocol for Cloudflare Tunnel is safer and more reliable.

Additional Knowledge: HTTP/2 and Long-Connection Applications

Long Connections Are Unstable When Using QUIC

When using Cloudflare Tunnel, choosing different communication protocols (QUIC or HTTP/2) will directly affect the stability of long connections, especially when complex network environments or specific application scenarios are involved. I have seen many articles mentioning that when using the default QUIC as the communication protocol, long-connection applications (such as gRPC) can be unstable. This is because although the QUIC protocol is designed to support long connections, long connections may experience interruptions in specific scenarios, analyzed as follows:

(1) Network interference and blocking

• QUIC is based on UDP/443, while many network environments (especially firewalls or corporate networks) have strict restrictions or prioritize blocking UDP traffic. For connections that need to be maintained for a long time, this interference can cause frequent connection interruptions.

(2) Connection interruption caused by network switching

• Although QUIC supports connection migration (such as switching from Wi-Fi to a mobile network), in some network environments, switching may cause increased latency or brief connection interruptions, affecting the stability of long connections.

(3) Adaptation issues between application protocols and QUIC

• Some applications that require stable long connections (such as WebSocket, real-time communication) may be more sensitive to latency or interruptions, and the characteristics of QUIC may not adapt well to these requirements.

(4) The reliability of QUIC depends on the stability of UDP

• If the network packet loss rate is high, the connectionless nature of UDP may cause the performance of QUIC's long connections to degrade.

Using HTTP/2 to Improve Long Connections

HTTP/2 is based on TCP/443, and its design is naturally suited for scenarios that require maintaining stable connections for a long time. Setting the http2 connection feature can further enhance the stability of long connections, for the following reasons:

(1) Reliability of TCP

• TCP is a connection-oriented protocol that provides packet transmission acknowledgment and retransmission mechanisms. In the event of packet loss or network jitter, TCP can more reliably guarantee data transmission and maintain the stability of long connections.

(2) Advantages of HTTP/2 multiplexing

• HTTP/2 supports transmitting multiple streams simultaneously over a single TCP connection, which means application-layer long connections can maintain multiplexed communication on a single connection, avoiding the risk of TCP connection exhaustion.

(3) The role of enabling http2 connection

• When the http2 connection feature is enabled in Cloudflare Tunnel, the server and client can explicitly negotiate the use of the HTTP/2 protocol. This brings the following benefits:

• Application-layer optimization: Applications that support long connections (such as WebSocket, gRPC, etc.) can work more efficiently on the stream characteristics of HTTP/2.

• Less handshake overhead: Compared to HTTP/1.1, each long connection requires only one handshake, reducing protocol-level latency.

• Keeping connections more stable: Even in network environments with packet loss or minor interference, TCP's retransmission mechanism and HTTP/2's multiplexing feature together ensure connection continuity.

(4) Synergy between TLS and HTTP/2

• The HTTP/2 protocol requires encrypted communication (TLS) and explicitly specifies the use of the HTTP/2 protocol through ALPN (Application-Layer Protocol Negotiation) This negotiation mechanism can effectively avoid instability caused by protocol switching. Therefore, in scenarios requiring stable long connections, switching to HTTP/2 and correctly configuring Cloudflare Tunnel is a better choice (mainly enabling the http2 connection option; see the practical operation section below for specific configurations).

Configuring Cloudflare Tunnel to Use the HTTP/2 Protocol

Configuration for Debian (Red Hat) Deployment

Go to Zero Trust -> Networks -> Tunnels, then select the tunnel corresponding to the connector you want to deploy on Debian. Taking my tunnel ”aliyuncloud” as an example, click ”Configure” under the 3 vertical dots on the far right to enter the overview interface:

image.png

image.png

Use a text editing tool to edit the configuration file, taking vim as an example:

vim /etc/systemd/system/cloudflared.service

Then add at the end of the ”ExecStart=” line:

--protocol http2

Then save and exit, as shown in the figure below:

image.png

Finally, use the following commands to reload systemd and restart the cloudflared service:

systemctl daemon-reload
systemctl restart cloudflared

You can also use the following command to view the logs:

journalctl -u cloudflared -f

Normally, you should see HTTP/2-related content, such as: ”Connected to Cloudflare edge using HTTP/2".

Note: If Cloudflare Tunnel has already been installed, simply edit the configuration file, save it, and restart the cloudflared service.

Configuration for Docker Deployment

image.png

Then add ”--protocol http2" to the command and run it:

docker run cloudflare/cloudflared:latest tunnel --no-autoupdate --protocol http2 run --token 你的token

Note: ”http2" in "--protocol http2" can also be replaced with "auto". This way, when the tunnel is established, it will try QUIC first, and if it fails, it will switch to HTTP/2.

Win and Mac

Modifying the protocol to HTTP/2 for Cloudflare Tunnel under Windows and macOS relies on modifying the ”config.yml” file. The content of the yml file is as follows:

tunnel: <tunnel-id>
credentials-file: /path/to/credentials.json

ingress:
  - hostname: example.com
    service: https://localhost:8080
    originRequest:
      http2: true # 启用 HTTP/2
  - service: http_status:404

Where:
• tunnel is your Tunnel ID.
• credentials-file is the path to the credentials file generated during login.
• http2: true is used to enable the HTTP/2 protocol.

Then use the following command:

cloudflared tunnel --config /path/to/config.yml run <tunnel-name>

Note: I have not actually verified this part; it was just collected, as I really don't want to install cloudflared on macOS and Windows~.

Optimizing Long Connections

In Cloudflare Tunnel, configuring Public Hostname and selecting the HTTPS service type can further optimize the experience of HTTP/2 long connections:

Public Hostname provides global accessibility

• Public Hostname is the entry point provided by Cloudflare, ensuring that the tunnel can route the optimal path globally, improving service availability even in complex networks.

Service Type Selection: HTTPS

• HTTPS forces all communication to be encrypted, which, combined with the multiplexing provided by HTTP/2, makes connections more efficient and stable.

Combined with HTTP/2 connection Features

• Explicitly enabling HTTP/2 allows applications requiring long connections (such as real-time communication services and continuous data streams) to remain stable under complex network conditions.

The specific steps are shown in the image below:

image.png

image.png

Summary

Actually, I originally wanted to directly add the command to switch the default protocol to HTTP/2 into my previously written article about Cloudflare Tunnel deployment. However, on second thought, although this operation is very simple, from the perspective of importance, it is completely worth dedicating a separate article to: because I believe many friends using Cloudflare Tunnel might not know this knowledge point yet.

P.S. For personal bloggers in China who use Cloudflare Tunnel to publish websites, I recommend trying to use HTTP/2 as much as possible in the future (even if the default QUIC protocol currently works fine). After all, you know why~.

View Related Categories · 3 Matches
📌 Content Structure Prompt:
This content is part of the following knowledge map, where you can view the complete content path: Cloudflare Learning Map。
📎 Related Articles
Share this article
The blog content is original, please indicate the source when reposting! The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if needed, you can join theTelegram Groupto discuss questions together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗ
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Kaomoji
Emoji
Little Dinosaur
Flower!
Previous
Next
       

👋 Welcome to “Wudi's Personal Blog”

Here, long-term exploration is mainly carried out around the following directions:

🧱 Personal Digital Infrastructure and Blog System Construction
☁️ Cloudflare and Network Architecture Practice
🧠 AI and Knowledge System Exploration
🛡️ Network Security and Access Optimization
🎵 Music and Sound Cognition
👁️ Cognitive Perspectives and Worldviews