Skip to main content
Version: 3.10.x

Disable HTTP/2 on Gateway Listeners

API7 Gateway applies HTTP/2 to all client-facing HTTP and HTTPS proxy listeners in the same process. If one listener enables HTTP/2, every proxy port accepts it. Native gRPC traffic therefore cannot be isolated to one listener without a separate gateway deployment.

The setting does not affect stream, Admin API, status, or metrics listeners. REST-to-gRPC and gRPC-Web clients can continue over HTTP/1.1 because the gateway translates those requests before calling the native gRPC upstream.

Complete the change by updating every proxy listener, rolling out all gateway instances, and verifying both the generated configuration and fresh client connections.

Prerequisites​

  • Shell access to each gateway host or container, plus Docker or kubectl for containerized deployments.
  • A curl build with HTTP/2 support. When the gateway certificate uses a private CA, also prepare that CA certificate for verification.
  • Inventory the effective HTTP and HTTPS listeners on every gateway instance.
  • Identify any native gRPC clients that require HTTP/2.
  • Confirm where TLS terminates and how to connect directly to each gateway instance. Testing only through a load balancer can hide a gateway that still accepts HTTP/2.

Update the Gateway Configuration​

Disable HTTP/2 on every plaintext and HTTPS proxy listener. Leaving it enabled on one listener keeps HTTP/2 enabled for the shared proxy server.

Do not add a second listener to isolate native gRPC in the same gateway process. Use a separate gateway group or deployment when native gRPC requires a different protocol boundary, and restrict that deployment's network exposure.

Back up the persistent gateway configuration and keep the backup until verification succeeds. Merge the following fragment into the complete active file; do not replace the file or its other settings:

config.yaml
apisix:
node_listen:
- port: 9080
enable_http2: false
ssl:
enable: true
listen:
- port: 9443
enable_http2: false

❶ Disables HTTP/2 on the plaintext proxy listener.

❷ Disables HTTP/2 on the HTTPS proxy listener.

Numeric plaintext entries, such as - 9080, and listener objects without the option already disable HTTP/2. Use the object form only when you need to set the option explicitly or preserve other listener fields.

Validate the complete configuration before replacing the running workers:

sudo apisix test && \
sudo systemctl restart api7-gateway

A reload starts new workers but can leave existing HTTP/2 connections on old workers until they drain. Restart or recreate the gateway when those connections must close before verification.

Verify HTTP/2 Is Disabled​

Inspect the Generated Configuration​

Check every current gateway container or pod. HTTP/2 is disabled only when the generated proxy server contains no http2 on; directive.

if grep -q "^[[:space:]]*http2 on;" /usr/local/apisix/conf/nginx.conf; then
echo "HTTP/2 is still enabled" >&2
exit 1
fi
echo "HTTP/2 is disabled"

If you reloaded a gateway instead of replacing its process, check for an old worker that is still draining:

ps -eo pid,args | grep "[w]orker process"

Wait until the output contains no worker process is shutting down entry before treating existing connections as drained.

Test HTTPS Listeners​

Open a fresh connection to each HTTPS listener with a curl build that supports HTTP/2:

export GATEWAY_IP="YOUR_GATEWAY_IP"

curl --http2 --silent --show-error --output /dev/null \
--write-out '%{http_version}\n' \
--noproxy gateway.example.com \
--resolve "gateway.example.com:9443:$GATEWAY_IP" \
"https://gateway.example.com:9443/health-check-path"

Replace the hostname, port, address, and path with values for the instance being tested. The command connects directly to the gateway while retaining the hostname for SNI and certificate verification. Add --cacert /path/to/ca.crt when the gateway certificate uses a private CA.

The command prints 1.1 when TLS negotiates HTTP/1.1.

Test Plain Text Listeners​

First confirm that an ordinary HTTP/1.1 request reaches the plaintext listener:

export GATEWAY_IP="YOUR_GATEWAY_IP"
export GATEWAY_HTTP_URL="http://$GATEWAY_IP:9080/health-check-path"

curl --http1.1 --silent --show-error --output /dev/null \
--write-out '%{http_version}\n' \
--noproxy "$GATEWAY_IP" \
-H "Host: gateway.example.com" \
"$GATEWAY_HTTP_URL"

The command prints 1.1 and exits successfully. Then send the HTTP/2 connection preface on a new connection:

curl --http2-prior-knowledge --silent --show-error --output /dev/null \
--write-out '%{http_version}\n' \
--noproxy "$GATEWAY_IP" \
-H "Host: gateway.example.com" \
"$GATEWAY_HTTP_URL"

When HTTP/2 is disabled, the prior-knowledge command exits nonzero because the listener does not return the HTTP/2 settings frame. A successful command that prints 2 means HTTP/2 is still enabled. The initial HTTP/1.1 request distinguishes the expected failure from an unreachable listener.

Restore HTTP/2​

Restore the required listener or Helm setting and roll out every gateway instance again. Verify that the intended native gRPC request succeeds through each updated instance.