H2O

the optimized HTTP/1.x, HTTP/2 server
Powered by Oktavia

Configure > Proxy Directives

Proxy module is the reverse proxy implementation for H2O - it implements a HTTP client that forwards a HTTP request to an upstream server.

When forwarding the requests, the module sets following request headers:

The HTTP client only supports HTTP/1 over TLS; neither HTTP/2 nor HTTPS are supported for the time being.

Following sections describe the configuration directives defined for the module.

"proxy.reverse.url"

Description:

Forwards the requests to the specified URL, and proxies the response.

Example. Forwarding the requests to application server running on 127.0.0.1:8080
proxy.reverse.url: "http://127.0.0.1:8080/"

At the moment, only HTTP is supported. If you want load balancing multiple backends, replace 127.0.0.1 with hostname witch returns IP addresses via DNS or /etc/hosts.

In addition to TCP/IP over IPv4 and IPv6, the proxy handler can also connect to an HTTP server listening to a Unix socket. Path to the unix socket should be surrounded by square brackets, and prefixed with unix: (e.g. http://[unix:/path/to/socket]/path).

Level:
path

"proxy.preserve-host"

Description:

A boolean flag (ON or OFF) designating whether or not to pass Host header from incoming request to upstream.

Level:
global, host, path
Default:
proxy.preserve-host: OFF

"proxy.timeout.io"

Description:

Sets the upstream I/O timeout in milliseconds.

Level:
global, host, path
Default:
proxy.timeout.io: 30000

"proxy.timeout.keepalive"

Description:

Sets the upstream timeout for idle connections in milliseconds.

Upstream connection becomes non-persistent if the value is set to zero. The value should be set to something smaller than that being set at the upstream server.

Level:
global, host, path
Default:
proxy.timeout.keepalive: 2000

"proxy.websocket"

Description:

A boolean flag (ON or OFF) indicating whether or not to allow upgrading the proxied connection to the WebSocket protocol.

When set to ON, the proxied connection will be upgraded to a bi-directional tunnel stream if upgrading to WebSocket connection is permitted by the backend server (i.e. if the backend server responds to a WebSocket handshake with 101 status code).

Support for WebSocket is considered experimental for the time being and therefore is not yet turned on by default.

Level:
global, host, path
Default:
proxy.websocket: OFF

"proxy.websocket.timeout"

Description:

Sets idle timeout of a WebSocket connection being proxied.

Level:
global, host, path
Default:
proxy.websocket.timeout: 300000