Apache HTTP Server Version 2.4

Apache > HTTP Server > Documentation > Version 2.4 > Modules

# Apache Module mod_http2

Available Languages: en

Description: | Support for the HTTP/2 transport layer
Status: | Extension
Module Identifier: | h2_module
Source File: | mod_http2.c

### Summary

This module provides HTTP/2 (RFC 7540) support for the Apache HTTP Server.

This module relies on libnghttp2 to provide the core http/2 engine.

### Warning

This module is experimental. Its behaviors, directives, and defaults are subject to more change from release to release relative to other standard modules. Users are encouraged to consult the "CHANGES" file for potential updates.

### Directives

- Comments

## H2Direct Directive

Description: | H2 Direct Protocol Switch
Syntax: | `H2Direct on|off`
Default: | `H2Direct on (for non TLS)`
Context: | server config, virtual host
Status: | Extension
Module: | mod_http2

This directive toggles the usage of the HTTP/2 Direct Mode. This should be used inside a `<VirtualHost>` section to enable direct HTTP/2 communication for that virtual host. Direct communication means that if the first bytes received by the server on a connection match the HTTP/2 preamble, the HTTP/2 protocol is switched to immediately without further negotiation. This mode falls outside the RFC 7540 but has become widely implemented as it is very convenient for development and testing. By default the direct HTTP/2 mode is enabled.

### Example

    H2Direct on

## H2MaxSessionStreams Directive

Description: | Maximum number of active streams per HTTP/2 session.
Syntax: | `H2MaxSessionStreams n`
Default: | `H2MaxSessionStreams 100`
Context: | server config, virtual host
Status: | Extension
Module: | mod_http2

This directive sets the maximum number of active streams per HTTP/2 session (e.g. connection) that the server allows. A stream is active if it is not `idle` or `closed` according to RFC 7540.

### Example

    H2MaxSessionStreams 20

## H2MaxWorkerIdleSeconds Directive

Description: | Maximum number of seconds h2 workers remain idle until shut down.
Syntax: | `H2MaxWorkerIdleSeconds n`
Default: | `H2MaxWorkerIdleSeconds 600`
Context: | server config
Status: | Extension
Module: | mod_http2

This directive sets the maximum number of seconds a h2 worker may idle until it shuts itself down. This only happens while the number of h2 workers exceeds `H2MinWorkers`.

### Example

    H2MaxWorkerIdleSeconds 20

## H2MaxWorkers Directive

Description: | Maximum number of worker threads to use per child process.
Syntax: | `H2MaxWorkers n`
Context: | server config
Status: | Extension
Module: | mod_http2

This directive sets the maximum number of worker threads to spawn per child process for HTTP/2 processing. If this directive is not used, `mod_http2` will chose a value suitable for the `mpm` module loaded.

### Example

    H2MaxWorkers 20

## H2MinWorkers Directive

Description: | Minimal number of worker threads to use per child process.
Syntax: | `H2MinWorkers n`
Context: | server config
Status: | Extension
Module: | mod_http2

This directive sets the minimum number of worker threads to spawn per child process for HTTP/2 processing. If this directive is not used, `mod_http2` will chose a value suitable for the `mpm` module loaded.

### Example

    H2MinWorkers 10

## H2SerializeHeaders Directive

Description: | Serialize Request/Resoonse Processing Switch
Syntax: | `H2SerializeHeaders on|off`
Default: | `H2SerializeHeaders off`
Context: | server config, virtual host
Status: | Extension
Module: | mod_http2

This directive toggles if HTTP/2 requests shall be serialized in HTTP/1.1 format for processing by `httpd` core or if received binary data shall be passed into the `request_rec`s directly.

Serialization will lower performance, but gives more backward compatibility in case custom filters/hooks need it.

### Example

    H2SerializeHeaders on

## H2SessionExtraFiles Directive

Description: | Number of Extra File Handles
Syntax: | `H2SessionExtraFiles n`
Default: | `H2SessionExtraFiles 5`
Context: | server config, virtual host
Status: | Extension
Module: | mod_http2

This directive sets maximum number of extra file handles a HTTP/2 session is allowed to use. A file handle is counted as extra when it is transfered from a h2 worker thread to the main HTTP/2 connection handling. This commonly happens when serving static files.

Depending on the processing model configured on the server, the number of connections times number of active streams may exceed the number of file handles for the process. On the other hand, converting every file into memory bytes early results in too many buffer writes. This option helps to mitigate that.

The number of file handles used by a server process is then in the order of:

    (h2_connections * extra_files) + (h2_max_worker)

### Example

    H2SessionExtraFiles 10

## H2StreamMaxMemSize Directive

Description: | Maximum amount of output data buffered per stream.
Syntax: | `H2StreamMaxMemSize bytes`
Default: | `H2StreamMaxMemSize 65536`
Context: | server config, virtual host
Status: | Extension
Module: | mod_http2

This directive sets the maximum number of outgoing data bytes buffered in memory for an active streams. This memory is not allocated per stream as such. Allocations are counted against this limit when they are about to be done. Stream processing freezes when the limit has been reached and will only continue when buffered data has been sent out to the client.

### Example

    H2StreamMaxMemSize 128000

## H2WindowSize Directive

Description: | Size of Stream Window for upstream data.
Syntax: | `H2WindowSize bytes`
Default: | `H2WindowSize 65536`
Context: | server config, virtual host
Status: | Extension
Module: | mod_http2

This directive sets the size of the window that is used for flow control from client to server and limits the amount of data the server has to buffer. The client will stop sending on a stream once the limit has been reached until the server announces more available space (as it has processed some of the data).

This limit affects only request bodies, not its meta data such as headers. Also, it has no effect on response bodies as the window size for those are managed by the clients.

### Example

    H2WindowSize 128000

Available Languages: en

## Comments

Notice:
This is not a Q&A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our mailing lists.