ruby-nginx 1.0.0.pre.beta.3 → 1.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 23ed81e982f332b222ea6f29a2e223ad1e114e5fb57953277defad3a164ca383
4
- data.tar.gz: b68c5854801f99463f05401990c434d6dbe8de74f401c03a6b2edd5a6fb13019
3
+ metadata.gz: 7e053789e61b0bf22afb92ea549a0ecb68bc4615761ae7342ff246e095100932
4
+ data.tar.gz: de3c4bd02f4745cca14cbf15f034a5187c10d3cddd083b1948ab63d9d958a6d2
5
5
  SHA512:
6
- metadata.gz: 7446042ae6a1a49eb49f034a455497d3a7eb4032800e124520db8ba74ef0a937a394de8b24cd58bb7cc12340b1d569574e5ef4e9fae0d25eeb3131d499979833
7
- data.tar.gz: d3b9bc26b024f25b1925f7f18a51bd0a13f0753434458b6fc6ce4d9c59cfed661b534522b84851220bc16327f5654ad7dd00d85878b5dd3c3088ed2c21a452a1
6
+ metadata.gz: 154b601c107623263d962fdcb5832d8143a579e2725dfe8788f7f764aa6fed22d7bf955ed248227385e484e9183008fb5231eae078c39febe7491f4e309a9bfa
7
+ data.tar.gz: 128c4ff6ae5b29351872953e7597ed900219178855ea4f53f9953ce3b31973b71dfb4e429710fac82339072811d4c8b9286994ae575d67d6eba1d4571865c8a2
data/README.md CHANGED
@@ -156,6 +156,7 @@ Options:
156
156
  -r, [--root-path=ROOT_PATH] # default: $PWD
157
157
  -s, [--ssl], [--no-ssl], [--skip-ssl] # default: false
158
158
  -l, [--log], [--no-log], [--skip-log] # default: false
159
+ -t, [--template-path=TEMPLATE_PATH] # default: [GEM_PATH]/nginx/templates/nginx.conf
159
160
  -cert-file, [--ssl-certificate-path=SSL_CERTIFICATE_PATH] # default: ~/.ruby-nginx/certs/_[DOMAIN].pem
160
161
  -key-file, [--ssl-certificate-key-path=SSL_CERTIFICATE_KEY_PATH] # default: ~/.ruby-nginx/certs/_[DOMAIN]-key.pem
161
162
  -access-log, [--access-log-path=ACCESS_LOG_PATH] # default: ~/.ruby-nginx/logs/[DOMAIN].access.log
@@ -25,6 +25,7 @@ module Ruby
25
25
  method_option :root_path, aliases: "-r", type: :string, desc: "default: $PWD"
26
26
  method_option :ssl, aliases: "-s", type: :boolean, desc: defaults(:ssl)
27
27
  method_option :log, aliases: "-l", type: :boolean, desc: defaults(:log)
28
+ method_option :template_path, aliases: "-t", type: :string, desc: "default: [GEM_PATH]/nginx/templates/nginx.conf"
28
29
  method_option :ssl_certificate_path, aliases: "-cert-file", type: :string, desc: default_paths(:ssl_certificate_path)
29
30
  method_option :ssl_certificate_key_path, aliases: "-key-file", type: :string, desc: default_paths(:ssl_certificate_key_path)
30
31
  method_option :access_log_path, aliases: "-access-log", type: :string, desc: default_paths(:access_log_path)
@@ -35,6 +36,7 @@ module Ruby
35
36
  port: options.port,
36
37
  host: options.host,
37
38
  root_path: options.root_path,
39
+ template_path: options.template_path,
38
40
  ssl: options.ssl,
39
41
  log: options.log,
40
42
  ssl_certificate_path: options.ssl_certificate_path,
@@ -33,10 +33,11 @@ module Ruby
33
33
  validate!
34
34
  apply_dynamic_defaults!
35
35
 
36
+ create_temp_path!
36
37
  create_ssl_certs! if options[:ssl]
37
38
  create_log_files! if options[:log]
38
39
 
39
- ERB.new(File.read(options[:template_path])).result(binding)
40
+ ERB.new(load_template).result(binding)
40
41
  end
41
42
 
42
43
  def defaults
@@ -51,6 +52,7 @@ module Ruby
51
52
 
52
53
  def default_paths
53
54
  {
55
+ temp_path: default_path("tmp"),
54
56
  ssl_certificate_path: default_path("certs/_#{options[:domain]}.pem"),
55
57
  ssl_certificate_key_path: default_path("certs/_#{options[:domain]}-key.pem"),
56
58
  access_log_path: default_path("logs/#{options[:domain]}.access.log"),
@@ -82,6 +84,20 @@ module Ruby
82
84
  self.options = default_paths.merge(options)
83
85
  end
84
86
 
87
+ def load_template
88
+ File.read(options[:template_path])
89
+ rescue Errno::EISDIR
90
+ raise Ruby::Nginx::AbortError, "Template is a directory: #{options[:template_path]}"
91
+ rescue Errno::ENOENT
92
+ raise Ruby::Nginx::AbortError, "Template does not exist at: #{options[:template_path]}"
93
+ rescue => e
94
+ raise Ruby::Nginx::AbortError, "Failed to read template.", cause: e
95
+ end
96
+
97
+ def create_temp_path!
98
+ options[:temp_path] = System::SafeFile.mkdir(options[:temp_path])
99
+ end
100
+
85
101
  def create_ssl_certs!
86
102
  System::Mkcert.create!(
87
103
  options[:domain],
@@ -7,6 +7,14 @@ module Ruby
7
7
  module System
8
8
  class SafeFile
9
9
  class << self
10
+ def mkdir(dir_path)
11
+ safe_path = File.expand_path(dir_path)
12
+
13
+ FileUtils.mkdir_p(dir_path)
14
+
15
+ safe_path
16
+ end
17
+
10
18
  def touch(file_path)
11
19
  safe_path = File.expand_path(file_path)
12
20
 
@@ -54,11 +54,15 @@ server {
54
54
  error_log <%= options[:error_log_path] %> warn;
55
55
  <% end %>
56
56
 
57
+ # Do not use the default proxy_temp_path, this is to avoid directory permissions issues.
58
+ proxy_temp_path <%= options[:temp_path] %> 1 2;
59
+
57
60
  # reverse proxy
58
61
  location @<%= name %> {
59
62
  proxy_pass http://<%= name %>;
60
63
  proxy_http_version 1.1;
61
- proxy_cache_bypass $http_upgrade;
64
+ proxy_no_cache 1;
65
+ proxy_cache_bypass 1;
62
66
 
63
67
  <% if options[:ssl] %>
64
68
  # proxy SSL
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Ruby
4
4
  module Nginx
5
- VERSION = "1.0.0-beta.3"
5
+ VERSION = "1.0.0"
6
6
 
7
7
  Version = Gem::Version
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-nginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.beta.3
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bert McCutchen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-02-11 00:00:00.000000000 Z
11
+ date: 2025-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb