Method: Puma::DSL#bind

Defined in:
lib/puma/dsl.rb

#bind(url) ⇒ Object

Bind the server to url. “tcp://”, “unix://” and “ssl://” are the only accepted protocols. Multiple urls can be bound to, calling bind does not overwrite previous bindings.

The default is “tcp://0.0.0.0:9292”.

You can use query parameters within the url to specify options:

  • Set the socket backlog depth with backlog, default is 1024.

  • Set up an SSL certificate with key & cert.

  • Set up an SSL certificate for mTLS with key, cert, ca and verify_mode.

  • Set whether to optimize for low latency instead of throughput with low_latency, default is to not optimize for low latency. This is done via Socket::TCP_NODELAY.

  • Set socket permissions with umask.

Examples:

Backlog depth

bind 'unix:///var/run/puma.sock?backlog=512'

SSL cert

bind 'ssl://127.0.0.1:9292?key=key.key&cert=cert.pem'

SSL cert for mutual TLS (mTLS)

bind 'ssl://127.0.0.1:9292?key=key.key&cert=cert.pem&ca=ca.pem&verify_mode=force_peer'

Disable optimization for low latency

bind 'tcp://0.0.0.0:9292?low_latency=false'

Socket permissions

bind 'unix:///var/run/puma.sock?umask=0111'

See Also:



274
275
276
277
# File 'lib/puma/dsl.rb', line 274

def bind(url)
  @options[:binds] ||= []
  @options[:binds] << url
end