Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.

To enable HTTP/2 for a browser-facing site, configure the HTTPS virtual host or server block, make sure the server build includes its HTTP/2 module, and confirm that TLS supports ALPN. Apache uses mod_http2 and Protocols h2 http/1.1; Nginx uses ngx_http_v2_module and http2 on;. Validate the configuration before reloading, then check the protocol a client actually negotiated—syntax acceptance alone does not prove HTTP/2 is in use.

Before you change the configuration

HTTP/2 support is a combination of server capability and configuration. Apache implements it in mod_http2; Nginx implements it in ngx_http_v2_module. Confirm the module is available in the installed build before adding directives. A directive copied from a current guide may not be accepted by an older server release or a package built without the relevant module.

  • Identify the exact virtual host or server block serving the hostname you want to change.
  • Confirm that HTTPS already works for that hostname, including the correct certificate and key configuration.
  • Check the installed server version and its matching documentation. This is particularly important for Nginx syntax, which has changed in older tutorials.
  • Back up or version-control the configuration before editing so you can revert a failed change.

For normal browser traffic, configure HTTP/2 over HTTPS. Browsers generally use HTTP/2 on HTTPS URLs, and TLS Application-Layer Protocol Negotiation (ALPN) must be supported for the connection to negotiate HTTP/2. The Apache HTTP/2 guide discusses ALPN and TLS compatibility at the Apache HTTP/2 guide; Nginx documents the TLS requirement in its HTTP/2 module reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Enable HTTP/2 in Apache httpd

1. Check that mod_http2 is present and loaded

Apache’s module reference lists HTTP/2 support from httpd 2.4.17. That does not mean every package or custom build has the module enabled. For a source build, Apache’s guide says building the module requires libnghttp2 version 1.2.1 or later and the --enable-http2 configure option. For a packaged installation, inspect the actual package and loaded-module configuration rather than assuming the module is available.

If the module exists but the distribution has not already loaded it, the configuration directive is:

LoadModule http2_module modules/mod_http2.so

The module path can vary by installation. Use the path and module-loading conventions for your host; do not add a duplicate LoadModule line if the package already loads it.

2. Set protocols on the HTTPS virtual host

Add Protocols h2 http/1.1 to the TLS virtual host serving the target name. Example structure:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<VirtualHost *:443>
    ServerName example.com
    Protocols h2 http/1.1
    # Keep the host's existing TLS certificate and key settings here.
</VirtualHost>

Replace example.com and retain the site’s real certificate and key directives. Apache permits Protocols at server or virtual-host scope. Putting it in a virtual host limits the change to that host; a server-level directive has a broader scope. Apache treats the leftmost protocol as most preferred, so placing h2 first prefers HTTP/2 while retaining HTTP/1.1 as a fallback.

3. Check TLS compatibility

Apache’s guide says the SSL library must support ALPN and notes OpenSSL 1.0.2 as a minimum when using OpenSSL. Treat that version threshold as the guide’s compatibility detail, not as a complete current TLS recommendation: verify the actual SSL library and supported configuration on your deployment. The guide also warns that an unsuitable cipher suite can lead browsers to refuse HTTP/2 and fall back to HTTP/1.1.

Run the syntax check and reload only after it passes. On many installations the check is apachectl configtest; service names and reload commands depend on the operating system and package. Use the service manager and service unit appropriate to your host.

Enable HTTP/2 in Nginx

1. Check the installed build

Verify that the installed Nginx build includes ngx_http_v2_module. Nginx says the module is not built by default in source builds and is enabled with --with-http_v2_module. A distribution package may already include it, so establish what the installed package contains before considering a rebuild. The module’s availability and current syntax are documented in Nginx’s module reference.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

2. Add the HTTP/2 directive to the TLS server block

Nginx’s current official example separates the TLS listener from HTTP/2 enablement:

server {
    listen 443 ssl;
    http2 on;

    server_name example.com;
    ssl_certificate     /path/to/your/server.crt;
    ssl_certificate_key /path/to/your/server.key;

    # Keep the rest of the existing site configuration here.
}

Use the real certificate and key paths and preserve the rest of the working server block. The http2 on; form is the current documented example; older tutorials may show different syntax. If your installed Nginx rejects this directive, check that version’s documentation and package capabilities instead of changing syntax blindly.

For HTTP/2 over TLS, Nginx requires ALPN support. Its reference notes ALPN availability with OpenSSL 1.0.2 and later; verify the actual TLS library used by the installed build. After editing, run nginx -t. Reload using the service manager for the host only after the test succeeds.

Apache and Nginx configuration at a glance

Item Apache httpd Nginx
HTTP/2 implementation mod_http2 ngx_http_v2_module
Source-build requirement Apache’s guide specifies libnghttp2 1.2.1 or later and --enable-http2. Nginx’s reference specifies --with-http_v2_module; the module is not built by default in source builds.
HTTPS configuration Protocols h2 http/1.1, commonly in the TLS virtual host. listen 443 ssl; and http2 on; in the TLS server block.
Negotiation signal The HTTP2 environment flag. The $http2 variable, documented as h2 for HTTP/2 over TLS and h2c for cleartext.
Syntax validation apachectl configtest (common command; packaging can vary). nginx -t.

Verify that a client negotiated HTTP/2

A successful syntax test means the server accepted the configuration; it does not show which protocol a particular client negotiated. Check the request to the intended hostname with a client that supports HTTP/2, and inspect its reported protocol. Also verify that the request reaches the virtual host or server block you edited—another default or name-based host can serve the request instead.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Server-side signals can help with diagnosis. Apache exposes an HTTP2 environment flag. Nginx provides the $http2 variable, whose value identifies the negotiated protocol: h2 for HTTP/2 over TLS and h2c for cleartext. Consult the module references for the relevant configuration context and logging details: Apache mod_http2 and Nginx ngx_http_v2_module.

  1. Request the site’s HTTPS URL using an HTTP/2-capable client.
  2. Inspect the client’s negotiated protocol, or temporarily log the server-side protocol signal supported by your server.
  3. Repeat for the exact hostname and endpoint whose configuration you changed; a successful request to a different host does not verify this virtual host.

Troubleshooting when HTTP/2 is not negotiated

The configuration test reports an unknown directive or module error

Apache may not have mod_http2 installed or loaded; Nginx may lack ngx_http_v2_module, or its installed version may not support the syntax used. Check the installed build and version-specific documentation. Do not reload with an unvalidated configuration.

The test passes, but the client reports HTTP/1.1

  • Confirm the request is reaching the intended HTTPS virtual host or server block for that hostname.
  • Check that HTTP/2 is enabled in that block, rather than in a different host’s configuration.
  • Verify TLS ALPN support in the SSL library and server build.
  • For Apache, review TLS cipher compatibility; Apache specifically documents that an unsuitable cipher suite can result in browser fallback to HTTP/1.1.
  • Use a client that supports HTTP/2 and check the negotiated protocol rather than relying on the page loading successfully.

The change affects more hosts than intended

Review directive scope. Apache’s Protocols can be set at server or virtual-host level; a server-level setting applies more broadly than a host-specific setting. In Nginx, check which server block handles the requested name and listener. Move or adjust the directive only after confirming the effective configuration.

The reload fails after editing

Use the configuration test output to locate the syntax or module issue, restore the last known-good configuration if needed, and validate again before reloading. Reload commands and service names vary by operating system and packaging, so use the local service manager’s documented unit rather than assuming a universal command.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Cleartext HTTP/2, performance, and operational trade-offs

h2c is not the ordinary browser setup

h2 denotes HTTP/2 over TLS; h2c is cleartext HTTP/2. Apache still supports h2c, and its protocol list can include it—for example, Protocols h2 h2c http/1.1—but Apache’s guide notes that h2c has been removed from the current specification. Enable it only where a specific, intentional client or internal deployment requires it. It is not a substitute for the HTTPS configuration used by ordinary browser-facing sites.

HTTP/2 does not guarantee a faster site

HTTP/2 allows multiple streams over one TCP connection, but it does not change HTTP request/response semantics or guarantee a universal performance improvement. Results depend on the workload, network, TLS, and server behavior. Measure the site’s own traffic and resource use rather than treating protocol enablement as a performance result.

Account for Apache resources and avoid obsolete setup advice

Apache notes that HTTP/2 can increase resource consumption because it starts additional worker threads for HTTP/2 processing. For a busy site, monitor capacity after enabling it. Apache’s guide also says Server Push is deprecated and points toward Early Hints as an alternative; enabling Push is not a recommended step in a new HTTP/2 setup.

Or skip the browser setup

If the practical goal is to capture a page rather than configure your own browser automation, ScreenshotNeo is a website screenshot API and MCP server for developers. One GET request can return a PNG, JPEG, WebP, or PDF. It removes supported cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, failed loads, timeouts, and cache hits are not billed. AI agents can use its MCP server tools, including take_screenshot, get_page_info, and capture_pdf.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Example cURL request (replace YOUR_API_KEY with your key):

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000 screenshots. Sign up for 1,000 free screenshots a month, with no card required.

Further reading

Frequently Asked Questions

Does enabling HTTP/2 require buying a certificate?

The setup requires working HTTPS and TLS support, but the server documentation does not make certificate purchase a requirement.

Does HTTP/2 change how an application handles HTTP requests and responses?

No. HTTP/2 changes the protocol transport behavior, including allowing multiple streams over one TCP connection; it does not change HTTP request/response semantics.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.