- WebServer Configuration
Configure the WebServer using the Helidon configuration framework, either programmatically or via a configuration file.
Configuring the WebServer in your code
The easiest way to configure the WebServer is in your application code.
ServerConfiguration configuration = ServerConfiguration.builder()
.bindAddress(InetAddress.getLocalHost())
.port(8080)
.build();
WebServer webServer = WebServer.create(configuration, routing);content_copy
Configuring the WebServer in a configuration file
You can also define the configuration in a file.
WebServer configuration file
application.confwebserver {
port: 8080,
bind-address: "0.0.0.0",
}content_copy
Then, in your application code, load the configuration from that file.
WebServer initialization using the
application.conf file located on the classpathServerConfiguration configuration = ServerConfiguration.create(
Config.builder()
.sources(classpath("application.conf"))
.build());
WebServer webServer = WebServer.create(configuration, routing);content_copy
Configuration options
See all configuration options here.
Available socket configuration options:
| Configuration key | Default value | Java type | Description |
port | int | Port to open server socket on, defaults to an available ephemeral port | |
bind-address | all local addresses | String | Address to listen on (may be an IPV6 address as well) |
backlog | 1024 | int | Maximum length of the queue of incoming connections on the server socket. |
max-header-size | 8192 | int | Maximal number of bytes of all header values combined. Returns 400 if headers are bigger |
max-initial-line-length | 4096 | int | Maximal number of characters in the initial HTTP line. Returns 400 if line is longer |
timeout-millis | no timeout | long | Server socket timeout. |
receive-buffer-size | implementation default | int | Proposed value of the TCP receive window that is advertised to the remote peer on the server socket. |
max-chunk-size | 8192 | int | Maximal size of a chunk to read from incoming requests |
validate-headers | true | boolean | Whether to validate header names, if they contain illegal characters. |
initial-buffer-size | 128 | int | Initial size of buffer used to parse HTTP line and headers |
ssl | Object | Configuration of SSL, please see our SSL example in repository |