Skip to content

Commit 20e81a2

Browse files
Unbound bindings from Puma port configuration
1 parent a51885a commit 20e81a2

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

Gemfile.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
rails-nginx (1.0.0.pre.beta.5)
4+
rails-nginx (1.0.0.pre.beta.6)
55
puma
66
rails
77
ruby-nginx (>= 1.0.0.pre.beta.4)

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -67,32 +67,31 @@ gem install rails-nginx
6767

6868
Add the Puma plugin to your configuration, and limit it to your development environment.
6969

70-
**config/puma.rb**
70+
**File: config/puma.rb**
7171
```ruby
7272
plugin :rails_nginx if Rails.env.development?
7373
```
7474

75-
> [!IMPORTANT]
76-
> **If you skip this, NGINX reverse proxy will have a randomized port while Puma will not. The reverse proxy will not work.**
77-
>
78-
> Puma's `port` configuration option makes it impossible for Rails NGINX to assign a random open port back to Puma.
79-
>
80-
> To fix this issue, simply remove it from our Puma configuration.
75+
Then simply start Rails!
76+
77+
**Terminal**
78+
```
79+
> ./bin/rails
80+
```
81+
82+
OR
83+
84+
```
85+
> ./bin/rails -p 3001
86+
```
87+
88+
> [!NOTE]
89+
> Rails NGINX will clear all port bindings and assign back to Puma a random open port, or the provided Rails port parameter.
8190
>
82-
> **config/puma.rb**
91+
> The following Puma configuration will be **ignored**.
8392
> ```ruby
8493
> port ENV.fetch("PORT") { 3000 }
8594
> ```
86-
>
87-
> OR simply disable it in your development environment:
88-
> ```ruby
89-
> port ENV.fetch("PORT") { 3000 } unless Rails.env.development?
90-
> ```
91-
>
92-
> OR always manually provide an open port when starting Rails:
93-
> ```
94-
> ./bin/rails server -p 3001
95-
> ```
9695
9796
### Default Configuration
9897
By default, Rails NGINX will configure [Ruby NGINX](https://github.com/bert-mccutchen/ruby-nginx) with the following options. For the examples, pretend I have an application called "HelloWorld".

lib/puma/plugin/rails_nginx.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def rails_port!
3030
def config(puma_config)
3131
rails_port!
3232

33+
puma_config.clear_binds!
3334
puma_config.port Rails::Nginx.port
3435

3536
puma_config.on_booted do

lib/rails/nginx/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
module Rails
44
module Nginx
5-
VERSION = "1.0.0-beta.5"
5+
VERSION = "1.0.0-beta.6"
66
end
77
end

spec/support/dummy_server.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
ENV["SKIP_PROMPT"] = "true"
44
APP_PATH = File.expand_path("../dummy/config/application", __dir__)
5-
ARGV = ["server", "-p", "3001"]
5+
ARGV = ["server"]
66

77
class DummyServer
88
include Singleton

0 commit comments

Comments
 (0)