Skip to content

Commit

Permalink
Support Unix socket listener
Browse files Browse the repository at this point in the history
This removes the "port" directive in favor of "bind", and for
consistency also exchanges the "PORT" variable with "BIND".
This allows users to override the default TCP listener with not only
a different port, but also optionally with a Unix socket, by setting
a "BIND" environment variable, without having to modify puma.rb.

The default listener is additionally changed to localhost to improve
security in installations without customization.

Signed-off-by: Georg Pfuetzenreuter <[email protected]>
  • Loading branch information
tacerus committed Jan 31, 2024
1 parent 1feaf3e commit f71f8d0
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions config/puma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the socket Puma will listen on, can be tcp:// or unix://, defaults to localhost:3000
bind ENV.fetch("BIND") { "tcp://[::1]:#{ ENV.fetch('PORT', 3000) }" }

# Specifies the `environment` that Puma will run in.
#
Expand Down

0 comments on commit f71f8d0

Please sign in to comment.