For better scalability (epoll, kqueue) and to provide IPv6 as well as TLS support, the optional modules EV (4.0+), IO::Socket::IP (0.16+) and IO::Socket::SSL (1.75+) will be used automatically by Mojo::IOLoop if they are installed. Individual features can also be disabled with the MOJO_NO_IPV6 and MOJO_NO_TLS environment variables.

group

inactivity_timeout

Maximum amount of time in seconds a connection can be inactive before getting closed, defaults to the value of the MOJO_INACTIVITY_TIMEOUT environment variable or 15. Setting the value to 0 will allow connections to be inactive indefinitely.

listen

List of one or more locations to listen on, defaults to the value of the MOJO_LISTEN environment variable or http://*:3000.

# Allow multiple servers to use the same port (SO_REUSEPORT)
$daemon->listen(['http://*:8080?reuse=1']);
# Listen on IPv6 interface
$daemon->listen(['http://[::1]:4000']);
# Listen on two ports with HTTP and HTTPS at the same time
$daemon->listen([qw(http://*:3000 https://*:4000)]);
# Use a custom certificate and key
$daemon->listen(['https://*:3000?cert=/x/server.crt&key=/y/server.key']);
# Or even a custom certificate authority
$daemon->listen(
['https://*:3000?cert=/x/server.crt&key=/y/server.key&ca=/z/ca.crt']);

These parameters are currently available:

ca

ca=/etc/tls/ca.crt

Path to TLS certificate authority file.

cert

cert=/etc/tls/server.crt

Path to the TLS cert file, defaults to a built-in test certificate.

ciphers

ciphers=AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH

Cipher specification string.

key

key=/etc/tls/server.key

Path to the TLS key file, defaults to a built-in test key.

reuse

reuse=1

Allow multiple servers to use the same port with the SO_REUSEPORT socket option.