Documentation

You are viewing the documentation for the 2.6.0-M4 development release. The latest stable release series is 3.0.x.

§Configuring the Akka HTTP server backend

By default, Play uses the Akka HTTP server backend.

like the rest of Play, the Akka HTTP server backend is configured with Typesafe Config.

#
# Copyright (C) 2009-2017 Lightbend Inc. <https://www.lightbend.com>
#

# Configuration for Play's AkkaHttpServer
play {

  server {
    # The server provider class name
    provider = "play.core.server.AkkaHttpServerProvider"

    akka {
      # How long to wait when binding to the listening socket
      bindTimeout = 5 seconds

      # The idle timeout for an open connection after which it will be closed
      # Set to null to disable the timeout
      https.idleTimeout = 75 seconds
      http.idleTimeout = 75 seconds

      # How long a request takes until it times out
      requestTimeout = null

      # Enables/disables automatic handling of HEAD requests.
      # If this setting is enabled the server dispatches HEAD requests as GET
      # requests to the application and automatically strips off all message
      # bodies from outgoing responses.
      # Note that, even when this setting is off the server will never send
      # out message bodies on responses to HEAD requests.
      transparent-head-requests = off

      # If this setting is empty the server only accepts requests that carry a
      # non-empty `Host` header. Otherwise it responds with `400 Bad Request`.
      # Set to a non-empty value to be used in lieu of a missing or empty `Host`
      # header to make the server accept such requests.
      # Note that the server will never accept HTTP/1.1 request without a `Host`
      # header, i.e. this setting only affects HTTP/1.1 requests with an empty
      # `Host` header as well as HTTP/1.0 requests.
      # Examples: `www.spray.io` or `example.com:8080`
      default-host-header = ""

      # Enables/disables the addition of a `Remote-Address` header
      # holding the clients (remote) IP address.
      remote-address-header = off

      # The default value of the `Server` header to produce if no
      # explicit `Server`-header was included in a response.
      # If this value is the empty string and no header was included in
      # the request, no `Server` header will be rendered at all.
      server-header = ""
    }
  }

}

You can read more about the configuration settings in the Akka HTTP documentation.

Note: In dev mode, when you use the run command, your application.conf settings will not be picked up by the server. This is because in dev mode the server starts before the application classpath is available. There are several other options you’ll need to use instead.

Next: Configuring Netty Server Backend