Catalog / H2O Web Server Cheatsheet
H2O Web Server Cheatsheet
A concise guide to the H2O web server, covering configuration, key features, and useful commands.
Core Configuration
Basic Server Setup
H2O’s configuration is primarily managed through a YAML file. The default location is usually Example:
|
Explanation of main configuration directives:
|
TLS Configuration
|
Specifies TLS listener with cert and key:
|
|
Enable OCSP stapling:
|
|
Enables early hints for HTTP/2
|
Proxying Configuration
|
Reverse proxy to another server:
|
|
Preserves the original
|
|
Sets the keep-alive timeout.
|
Advanced Features
Caching
H2O provides flexible caching mechanisms. You can configure cache based on file extensions or specific paths. Example:
This caches static content for an hour. |
Explanation of caching directives:
|
Compression
|
Enables Gzip compression.
|
|
Enables Brotli compression (if available).
|
|
Add custom MIME types for files.
|
Request Handling
|
Forward requests to a FastCGI server:
|
|
Execute mruby scripts to handle requests.
|
Command-Line Usage
Basic Commands
|
Example:
Starts H2O using the |
Signal Handling
|
Graceful shutdown. |
|
Reopens log files. |
|
Initiates a graceful restart. |
Debugging
|
Enables verbose logging for debugging purposes. |
|
Check the error log file for any issues. |
Modules and Handlers
Built-in Modules
H2O comes with a variety of built-in modules that extend its functionality. Here’s a brief overview:
|
Custom Handlers
mruby handlers: |
Allows executing mruby scripts for custom request handling.
|
External handlers: |
Use external programs to handle requests via HTTP or other protocols. |
Security
|
Configure access control rules based on IP addresses or other criteria.
|
|
Configures TLS ticket key for session resumption.
|