rails-nginx 1.0.0.pre.alpha.1 → 1.0.0.pre.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +149 -28
- data/lib/rails/nginx/version.rb +1 -1
- data/lib/rails/nginx.rb +6 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b509ef92a5f9976f4a3861fef1049fd3d2002cc28600292da5221898508712b7
|
4
|
+
data.tar.gz: a2dfd4812dfedbfed4d50c0d03b930fbd8d37c3eae58d31ec9e3f6ce94fb98a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2f8e5d2cd168828389987d512b4fc44000b0556ffff35c131f3a16c716fed5ea6a4292099e6d8106be725ec1c28fb0b0dd1a96423193440757e1b381eb2713f
|
7
|
+
data.tar.gz: 01f238f9c4e310ff12f41d19dd44ebbf319d040ebb1c95f8cd0dc5d14a700f8e7b573f75f0016377105f14668e33544114c86a714867f4d8bdca199781435589
|
data/README.md
CHANGED
@@ -1,15 +1,39 @@
|
|
1
1
|
# Rails NGINX
|
2
2
|
|
3
|
-
|
3
|
+
Rails Puma plugin convenience wrapper for Ruby NGINX. Take a look at the [Ruby NGINX project documentation](https://github.com/bert-mccutchen/ruby-nginx) for more in depth details.
|
4
4
|
|
5
|
-
|
6
|
-
2. Mkcert for SSL certificate generation.
|
7
|
-
3. Tried and true NGINX for reverse proxying.
|
5
|
+
:heart: ERB for NGINX configuration templating.
|
8
6
|
|
9
|
-
|
7
|
+
:yellow_heart: Self-signed certificate generation via mkcert for HTTPS.
|
8
|
+
|
9
|
+
:green_heart: Tried and true NGINX for reverse proxying, and hosts mapping for DNS.
|
10
10
|
|
11
11
|
[](https://ko-fi.com/M4M76DVZR)
|
12
12
|
|
13
|
+
---
|
14
|
+
|
15
|
+
> [!WARNING]
|
16
|
+
>This gem is intended to be an aid to your development environment - powered by [Ruby NGINX](https://github.com/bert-mccutchen/ruby-nginx). **Don't use this gem in production.**
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
### Contents
|
21
|
+
|
22
|
+
- [Installation](#installation)
|
23
|
+
- [Usage](#usage)
|
24
|
+
- [Basic Usage](#basic-usage)
|
25
|
+
- [Default Configuration](#default-configuration)
|
26
|
+
- [Advanced Usage](#advanced-usage)
|
27
|
+
- [Multiple Configurations](#multiple-configurations)
|
28
|
+
- [Inheriting Configurations](#inheriting-configurations)
|
29
|
+
- [Development](#development)
|
30
|
+
- [Setup](#setup)
|
31
|
+
- [Lint / Test](#lint--test)
|
32
|
+
- [Debug Console](#debug-console)
|
33
|
+
- [Release](#release)
|
34
|
+
- [Contributing](#contributing)
|
35
|
+
- [License](#license)
|
36
|
+
|
13
37
|
## Installation
|
14
38
|
|
15
39
|
Install via Bundler:
|
@@ -24,44 +48,141 @@ gem install rails-nginx
|
|
24
48
|
|
25
49
|
## Usage
|
26
50
|
|
27
|
-
###
|
28
|
-
|
29
|
-
|
51
|
+
### Basic Usage
|
52
|
+
|
53
|
+
Add the Puma plugin to your configuration, and limit it to your development environment.
|
30
54
|
|
55
|
+
**config/puma.rb**
|
56
|
+
```ruby
|
31
57
|
plugin :rails_nginx if Rails.env.development?
|
58
|
+
```
|
32
59
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
60
|
+
> [!IMPORTANT]
|
61
|
+
> **If you skip this, NGINX reverse proxy will have a randomized port while Puma will not. The reverse proxy will not work.**
|
62
|
+
>
|
63
|
+
> Puma's `port` configuration option makes it impossible for Rails NGINX to assign a random open port back to Puma.
|
64
|
+
>
|
65
|
+
> To fix this issue, simply remove it from our Puma configuration.
|
66
|
+
>
|
67
|
+
> **config/puma.rb**
|
68
|
+
> ```ruby
|
69
|
+
> port ENV.fetch("PORT") { 3000 }
|
70
|
+
> ```
|
71
|
+
>
|
72
|
+
> OR simply disable it in your development environment:
|
73
|
+
> ```ruby
|
74
|
+
> port ENV.fetch("PORT") { 3000 } unless Rails.env.development?
|
75
|
+
> ```
|
76
|
+
>
|
77
|
+
> OR always manually provide an open port when starting Rails:
|
78
|
+
> ```
|
79
|
+
> ./bin/rails server -p 3001
|
80
|
+
> ```
|
81
|
+
|
82
|
+
### Default Configuration
|
83
|
+
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".
|
84
|
+
|
85
|
+
| Option | Default | Example |
|
86
|
+
|---|---|---|
|
87
|
+
| `domain` | Your rails app name as dashes, with the test TLD. | `hello-world.test` |
|
88
|
+
| `host` | `127.0.0.1` | |
|
89
|
+
| `root_path` | `Rails.public_path` | `/home/bert/hello_world/public` |
|
90
|
+
| `ssl` | `true` | |
|
91
|
+
| `log` | `true` | |
|
92
|
+
| `ssl_certificate_path` | `Rails.root` + `tmp/nginx/_[DOMAIN].pem` | `/home/bert/hello_world/tmp/nginx/_hello-world.test.pem` |
|
93
|
+
| `ssl_certificate_key_path` | `Rails.root` + `tmp/nginx/_[DOMAIN]-key.pem` | `/home/bert/hello_world/tmp/nginx/_hello-world.test-key.pem` |
|
94
|
+
| `access_log_path` | `Rails.root` + `log/nginx/[DOMAIN].access.log` | `/home/bert/hello_world/log/hello-world.test.access.log` |
|
95
|
+
| `error_log_path` | `Rails.root` + `log/nginx/[DOMAIN].error.log` | `/home/bert/hello_world/log/hello-world.test.error.log` |
|
96
|
+
|
97
|
+
### Advanced Usage
|
98
|
+
|
99
|
+
You can override all the default values and provide your own configuration. Rails NGINX will use your configuration automatically if one is present. Default values are retained if not overridden.
|
100
|
+
|
101
|
+
**config/puma.rb**
|
102
|
+
```ruby
|
103
|
+
rails_nginx_config do |config|
|
104
|
+
config[:domain] = "example.test"
|
105
|
+
config[:host] = "localhost"
|
106
|
+
# etc.
|
107
|
+
end
|
108
|
+
```
|
109
|
+
|
110
|
+
#### Multiple Configurations
|
111
|
+
|
112
|
+
Let's say you have a multi-tenant Rails application, and you want to simulate the application running behind two separate domains in your development environment. No problem, Rails NGINX can support multiple configurations, no matter how wildly different they may be.
|
113
|
+
|
114
|
+
**config/puma.rb**
|
115
|
+
```ruby
|
116
|
+
rails_nginx_config(:work) do |config|
|
117
|
+
config[:domain] = "work.todo-list.test"
|
118
|
+
config[:ssl] = true
|
119
|
+
config[:log] = true
|
40
120
|
|
41
|
-
|
42
|
-
config[:
|
43
|
-
config[:ssl_certificate_key_path] = './tmp/certs/_spline-reticulator-key.test.pem'
|
121
|
+
config[:ssl_certificate_path] = "~/work/my-cert.pem"
|
122
|
+
config[:ssl_certificate_key_path] = "~/work/my-cert-key.pem"
|
44
123
|
|
45
124
|
# default location Rails.root + log/nginx/
|
46
|
-
config[:access_log_path] =
|
47
|
-
config[:error_log_path] =
|
125
|
+
config[:access_log_path] = "~/work/logs/todo-list.access.log"
|
126
|
+
config[:error_log_path] = "~/work/logs/todo-list.error.log"
|
127
|
+
end
|
128
|
+
|
129
|
+
rails_nginx_config(:home) do |config|
|
130
|
+
config[:domain] = "home.todo-list.test"
|
131
|
+
config[:ssl] = false
|
132
|
+
config[:log] = false
|
48
133
|
end
|
134
|
+
```
|
135
|
+
|
136
|
+
#### Inheriting Configurations
|
49
137
|
|
50
|
-
|
51
|
-
rails_nginx_config(:secondary) do |config|
|
52
|
-
config.merge!(rails_nginx_config(:primary))
|
138
|
+
Since Rails NGINX configurations are a simple Ruby Hash, you can merge configurations to prevent needless duplication. This is possible because Rails NGINX allows you to read back previously defined configurations.
|
53
139
|
|
54
|
-
|
55
|
-
|
56
|
-
|
140
|
+
**config/puma.rb**
|
141
|
+
```ruby
|
142
|
+
rails_nginx_config(:kids) do |config|
|
143
|
+
config.merge!(rails_nginx_config(:home))
|
144
|
+
|
145
|
+
config[:domain] = "kids.todo-list.test"
|
146
|
+
config[:log] = true
|
57
147
|
end
|
58
148
|
```
|
59
149
|
|
60
150
|
## Development
|
61
151
|
|
62
|
-
|
152
|
+
### Setup
|
153
|
+
|
154
|
+
Install development dependencies.
|
155
|
+
```
|
156
|
+
./bin/setup
|
157
|
+
```
|
158
|
+
|
159
|
+
### Lint / Test
|
160
|
+
|
161
|
+
Run the Standard Ruby linter, and RSpec test suite.
|
162
|
+
```
|
163
|
+
bundle exec rake
|
164
|
+
```
|
165
|
+
|
166
|
+
#### Generating a new Dummy server
|
167
|
+
|
168
|
+
There's a built-in executable if you'd like to generate a new Dummy server to upgrade the regression tests to work with the latest version of Rails.
|
169
|
+
|
170
|
+
This executable will delete the current `spec/dummy` directory, update the `rails` gem to the latest version, and generate a new `spec/dummy` application using the options defined in the `.dummy.railsrc` file.
|
171
|
+
```
|
172
|
+
./bin/dummy
|
173
|
+
```
|
174
|
+
|
175
|
+
### Debug Console
|
176
|
+
|
177
|
+
Start an interactive Ruby console (IRB).
|
178
|
+
```
|
179
|
+
./bin/console
|
180
|
+
```
|
181
|
+
|
182
|
+
### Release
|
183
|
+
|
184
|
+
A new release will automatically be built and uploaded to RubyGems by a [GitHub Actions workflow](./.github/workflows/gem-push.yml) upon the push of a new Git tag.
|
63
185
|
|
64
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
65
186
|
|
66
187
|
## Contributing
|
67
188
|
|
data/lib/rails/nginx/version.rb
CHANGED
data/lib/rails/nginx.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require "socket"
|
4
4
|
require "ruby/nginx"
|
5
|
-
require_relative "
|
5
|
+
require_relative "nginx/version"
|
6
6
|
|
7
7
|
module Rails
|
8
8
|
module Nginx
|
@@ -17,13 +17,17 @@ module Rails
|
|
17
17
|
|
18
18
|
config = Ruby::Nginx.add!(options.reverse_merge(defaults(options)), &block)
|
19
19
|
|
20
|
-
puts start_message(config.options)
|
20
|
+
puts start_message(config.options)
|
21
|
+
rescue Ruby::Nginx::Error => e
|
22
|
+
abort "[Ruby::Nginx] #{e.message}"
|
21
23
|
end
|
22
24
|
|
23
25
|
def self.stop!(options = {}, &block)
|
24
26
|
return unless rails_server?
|
25
27
|
|
26
28
|
Ruby::Nginx.remove!(options.reverse_merge(defaults(options)), &block)
|
29
|
+
rescue Ruby::Nginx::Error => e
|
30
|
+
abort "[Ruby::Nginx] #{e.message}"
|
27
31
|
end
|
28
32
|
|
29
33
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-nginx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bert McCutchen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: puma
|
@@ -74,7 +74,7 @@ metadata:
|
|
74
74
|
source_code_uri: https://github.com/bert-mccutchen/rails-nginx
|
75
75
|
changelog_uri: https://github.com/bert-mccutchen/rails-nginx/blob/main/CHANGELOG.md
|
76
76
|
rubygems_mfa_required: 'true'
|
77
|
-
post_install_message:
|
77
|
+
post_install_message:
|
78
78
|
rdoc_options: []
|
79
79
|
require_paths:
|
80
80
|
- lib
|
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
92
|
rubygems_version: 3.5.22
|
93
|
-
signing_key:
|
93
|
+
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Automatic NGINX+SSL configuration for Rails.
|
96
96
|
test_files: []
|