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);
Copied

Configuring the WebServer in a configuration file

You can also define the configuration in a file.

WebServer configuration file application.conf
webserver {
  port: 8080,
  bind-address: "0.0.0.0",
}
Copied

Then, in your application code, load the configuration from that file.

WebServer initialization using the application.conf file located on the classpath
ServerConfiguration configuration = ServerConfiguration.create(
        Config.builder()
              .sources(classpath("application.conf"))
              .build());

WebServer webServer = WebServer.create(configuration, routing);
Copied

Configuration options

See all configuration options here.

Available socket configuration options:

Configuration keyDefault valueJava typeDescription
port intPort to open server socket on, defaults to an available ephemeral port
bind-addressall local addressesStringAddress to listen on (may be an IPV6 address as well)
backlog1024intMaximum length of the queue of incoming connections on the server socket.
max-header-size8192intMaximal number of bytes of all header values combined. Returns 400 if headers are bigger
max-initial-line-length4096intMaximal number of characters in the initial HTTP line. Returns 400 if line is longer
timeout-millisno timeoutlongServer socket timeout.
receive-buffer-sizeimplementation defaultintProposed value of the TCP receive window that is advertised to the remote peer on the server socket.
max-chunk-size8192intMaximal size of a chunk to read from incoming requests
validate-headerstruebooleanWhether to validate header names, if they contain illegal characters.
initial-buffer-size128intInitial size of buffer used to parse HTTP line and headers
ssl ObjectConfiguration of SSL, please see our SSL example in repository