docker.recipes

H2O HTTP Server

intermediate

Optimized HTTP/1.x and HTTP/2 server with high performance.

Overview

H2O is a high-performance HTTP/1.x and HTTP/2 server developed by DeNA and optimized for speed and efficiency. Written in C with a focus on memory efficiency and low latency, H2O consistently ranks among the fastest web servers in benchmarks, particularly excelling at HTTP/2 connections and TLS termination. The server supports advanced features like HTTP/2 server push, mruby scripting for request manipulation, and sophisticated caching mechanisms that make it ideal for performance-critical applications. This Docker configuration deploys H2O with a custom configuration file and web content directory, enabling rapid deployment of a production-grade HTTP/2 server. The setup includes both HTTP and HTTPS ports with volume mounts for configuration and static content, making it suitable for high-traffic websites, API endpoints, and applications requiring optimal HTTP/2 performance. Organizations seeking maximum performance per resource unit will find H2O particularly valuable, as it delivers exceptional throughput while maintaining low memory footprint compared to traditional servers like Apache or Nginx. The mruby integration allows for sophisticated request handling logic without the overhead of external scripting languages, making this stack perfect for edge computing scenarios and latency-sensitive applications.

Key Features

  • Native HTTP/2 support with server push capabilities for preloading critical resources
  • mruby scripting integration for dynamic request handling and response manipulation
  • Extremely low memory footprint with efficient connection multiplexing
  • Advanced TLS optimization with session resumption and OCSP stapling
  • Built-in access logging with customizable format and rotation
  • Hot configuration reloading without connection drops
  • Sophisticated caching layer with cache-aware optimization
  • High-performance static file serving with sendfile optimization

Common Use Cases

  • 1High-traffic content delivery networks requiring maximum throughput per server
  • 2API gateways for microservices architectures demanding low latency responses
  • 3Edge computing deployments where resource efficiency is critical
  • 4Development environments testing HTTP/2 server push implementations
  • 5Load balancer frontends for distributing traffic across backend services
  • 6Static website hosting with advanced caching and compression requirements
  • 7WebSocket proxy servers handling thousands of concurrent connections

Prerequisites

  • Docker and Docker Compose installed with support for bind mounts
  • At least 512MB available RAM for optimal H2O performance
  • Ports 80 and 443 available on the host system
  • Basic understanding of YAML configuration format for h2o.conf
  • SSL/TLS certificates if enabling HTTPS functionality
  • Knowledge of HTTP/2 concepts for advanced feature utilization

For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms

docker-compose.yml

docker-compose.yml
1services:
2 h2o:
3 image: lkwg82/h2o-http2-server:latest
4 container_name: h2o
5 restart: unless-stopped
6 volumes:
7 - ./h2o/h2o.conf:/etc/h2o/h2o.conf:ro
8 - ./html:/var/www/html:ro
9 ports:
10 - "80:80"
11 - "443:443"
12 networks:
13 - h2o-network
14
15networks:
16 h2o-network:
17 driver: bridge

.env Template

.env
1# H2O configuration file required

Usage Notes

  1. 1Docs: https://h2o.examp1e.net/configure.html
  2. 2HTTP/2 optimized - excellent TLS performance
  3. 3Server push support for preloading assets
  4. 4mruby scripting for request handling logic
  5. 5Configure via h2o.conf - YAML format
  6. 6Benchmarks show among fastest HTTP/2 servers

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 h2o:
5 image: lkwg82/h2o-http2-server:latest
6 container_name: h2o
7 restart: unless-stopped
8 volumes:
9 - ./h2o/h2o.conf:/etc/h2o/h2o.conf:ro
10 - ./html:/var/www/html:ro
11 ports:
12 - "80:80"
13 - "443:443"
14 networks:
15 - h2o-network
16
17networks:
18 h2o-network:
19 driver: bridge
20EOF
21
22# 2. Create the .env file
23cat > .env << 'EOF'
24# H2O configuration file required
25EOF
26
27# 3. Start the services
28docker compose up -d
29
30# 4. View logs
31docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/h2o/run | bash

Troubleshooting

  • Container fails to start with 'configuration file not found': Ensure ./h2o/h2o.conf exists and contains valid YAML syntax
  • Permission denied accessing configuration files: Check that h2o.conf has appropriate read permissions (644) for the container user
  • HTTP/2 connections falling back to HTTP/1.1: Verify TLS is properly configured as HTTP/2 requires encryption in most browsers
  • High memory usage despite H2O's efficiency: Check mruby scripts for memory leaks or inefficient string operations
  • Static files not serving correctly: Ensure ./html directory exists with proper permissions and contains index files
  • Server push not working as expected: Verify push directives in h2o.conf and test with HTTP/2 capable tools like curl --http2

Community Notes

Loading...
Loading notes...

Download Recipe Kit

Get all files in a ready-to-deploy package

Includes docker-compose.yml, .env template, README, and license

Ad Space