h2o-configurator 0.5 → 0.6

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: 9aabac121ceb4c0d23fb3c192e63ec9c0c6d880fd342fca83f920f384ee6ea3d
4
- data.tar.gz: 4e48dcb4143a0c2ae0558f6f16bf3d3efa0ecedbb495b88ad80d5ec17e26bc15
3
+ metadata.gz: a1249082a62a2b5a079c0b020eb686567171128d7e890b91de8820c0af621f38
4
+ data.tar.gz: 4becf75eb92462af854556427571d5e0a387eda0444403f53a3e4d29e9bbe8a6
5
5
  SHA512:
6
- metadata.gz: c43dbe0b66c4d3fa6617c87be84a16a1e4a645e862f929f0322ffb2d6062a37eaed907a4c315c1c986bfca0fd73f6d1c7546749113151d9aacd886edfddcf899
7
- data.tar.gz: ea3d7fbac40494bf30414f1f5f150dd8a654a25a386e8cb97638295900830ad50da007548c7b73bbc6946215bba8dadddbbec79931d1a91ae4063d6ccd4b1f60
6
+ metadata.gz: b6de83ab48209998cd51512a4ef022531df7a51f41b7b3250128a0cf99c8fbe197c5d4a7696ba0141672cdeaa230a8dfd126c7919eaa518d86607795b95fb37b
7
+ data.tar.gz: 217c7cd7bd7546cca8ca3acc28ea889d8f11d0e25acdcc3f657d196ec177de5de4077ea6f5f287a19ad57955a83083111cb187f105cd5bb5b7decd0166da97ff
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,21 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ h2o-configurator (0.6)
5
+ path (~> 2.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ path (2.0.1)
11
+ rake (0.9.6)
12
+
13
+ PLATFORMS
14
+ x86_64-darwin-18
15
+
16
+ DEPENDENCIES
17
+ h2o-configurator!
18
+ rake (~> 0)
19
+
20
+ BUNDLED WITH
21
+ 2.2.3
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'h2o-configurator'
4
4
 
5
- configurator = H2OConfigurator::Builder.new
5
+ configurator = H2OConfigurator::Builder.new(ARGV.empty? ? nil : ARGV)
6
6
  begin
7
7
  configurator.write_config
8
8
  rescue H2OConfigurator::Error => e
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_dependency 'path', '~> 2.0'
24
24
 
25
- spec.add_development_dependency 'rake', '~> 0'
25
+ spec.add_development_dependency 'rake', '~> 13.0'
26
26
  end
@@ -2,7 +2,7 @@ require 'path'
2
2
  require 'yaml'
3
3
 
4
4
  require 'h2o-configurator/builder'
5
- require 'h2o-configurator/site'
5
+ require 'h2o-configurator/host'
6
6
  require 'h2o-configurator/version'
7
7
 
8
8
  module H2OConfigurator
@@ -21,8 +21,6 @@ module H2OConfigurator
21
21
  CertBaseDir = Path.new('/etc/letsencrypt/live')
22
22
  ServerCertificateFilename = 'fullchain.pem'
23
23
  PrivateKeyFilename = 'privkey.pem'
24
- DomainPrefixes = %w{www.}
25
- DomainSuffixes = %w{.test}
26
24
 
27
25
  class Error < Exception; end
28
26
 
@@ -2,17 +2,23 @@ module H2OConfigurator
2
2
 
3
3
  class Builder
4
4
 
5
+ def initialize(site_dirs=nil)
6
+ @site_dirs = site_dirs ? site_dirs.map { |p| Path.new(p) } : Path.glob(SitesDirGlob)
7
+ end
8
+
5
9
  def make_config
10
+ @site_dirs.reject! { |p| p.extname == '.old' || p.extname == '.new' }
11
+ raise "No sites defined" if @site_dirs.empty?
6
12
  config = {
7
13
  'compress' => 'ON',
8
14
  'reproxy' => 'ON',
9
15
  'error-log' => ErrorLogFile.to_s,
10
16
  'hosts' => {},
11
17
  }
12
- Path.glob(SitesDirGlob).reject { |p| p.extname == '.old' || p.extname == '.new' }.each do |site_dir|
13
- site = Site.new(site_dir)
14
- puts "%30s => %s" % [site.name, site.dir]
15
- config['hosts'].merge!(site.make_config)
18
+ @site_dirs.sort.each do |dir|
19
+ host = Host.new(dir)
20
+ puts "%30s => %s" % [host.name, host.dir]
21
+ config['hosts'].merge!(host.make_config)
16
22
  end
17
23
  config
18
24
  end
@@ -1,6 +1,6 @@
1
1
  module H2OConfigurator
2
2
 
3
- class Site
3
+ class Host
4
4
 
5
5
  attr_accessor :dir
6
6
  attr_accessor :name
@@ -11,44 +11,39 @@ module H2OConfigurator
11
11
  end
12
12
 
13
13
  def make_config
14
- config = {}
15
14
  if cert_dir.exist?
16
- https_redirect_host_config = make_https_redirect_host_config(80)
17
- host_config = make_host_config(443)
15
+ config_http = make_https_redirect_host_config(80)
16
+ config_https = make_host_config(443)
17
+ {
18
+ "#{@name}:80" => config_http,
19
+ "*.#{@name}:80" => config_http,
20
+ "#{@name}:443" => config_https,
21
+ "*.#{@name}:443" => config_https,
22
+ }
18
23
  else
19
- https_redirect_host_config = nil
20
- host_config = make_host_config(80)
21
- end
22
- domains.each do |domain|
23
- if https_redirect_host_config
24
- config["#{domain}:80"] = https_redirect_host_config
25
- config["#{domain}:443"] = host_config
26
- else
27
- config["#{domain}:80"] = host_config
28
- end
24
+ config_http = make_host_config(80)
25
+ {
26
+ "#{@name}:80" => config_http,
27
+ "*.#{@name}:80" => config_http,
28
+ }
29
29
  end
30
- config
31
- end
32
-
33
- def domains
34
- ([''] + DomainPrefixes).map do |prefix|
35
- ([''] + DomainSuffixes).map do |suffix|
36
- "#{prefix}#{@name}#{suffix}"
37
- end
38
- end.flatten
39
30
  end
40
31
 
41
32
  def make_host_config(port)
42
33
  config = {
43
- 'listen' => {
44
- 'port' => port,
45
- },
34
+ 'listen' => { 'port' => port },
46
35
  'access-log' => access_log_file.to_s,
47
36
  'setenv' => { 'HOST_DIR' => @dir.to_s },
48
- 'paths' => {
49
- '/' => make_handlers,
50
- },
51
37
  }
38
+ if proxy_reverse_url_file.exist?
39
+ config['paths'] = {
40
+ '/' => { 'proxy.reverse.url' => proxy_reverse_url_file.read.chomp }
41
+ }
42
+ else
43
+ config['paths'] = {
44
+ '/' => make_handlers
45
+ }
46
+ end
52
47
  if server_certificate_file.exist? && private_key_file.exist?
53
48
  config['listen']['ssl'] = {
54
49
  'certificate-file' => server_certificate_file.to_s,
@@ -121,6 +116,10 @@ module H2OConfigurator
121
116
  @dir / '.htpasswd'
122
117
  end
123
118
 
119
+ def proxy_reverse_url_file
120
+ @dir / '.proxy-reverse-url'
121
+ end
122
+
124
123
  def access_log_file
125
124
  H2OConfigurator::H2OLogDir / "#{@name}.access.log"
126
125
  end
@@ -1,5 +1,5 @@
1
1
  module H2OConfigurator
2
2
 
3
- VERSION = '0.5'
3
+ VERSION = '0.6'
4
4
 
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: h2o-configurator
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: '0.6'
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Labovitz
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-27 00:00:00.000000000 Z
11
+ date: 2020-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: path
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: '13.0'
41
41
  description: H2OConfigurator builds H2O config files.
42
42
  email:
43
43
  - johnl@johnlabovitz.com
@@ -47,6 +47,8 @@ extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
49
  - ".gitignore"
50
+ - Gemfile
51
+ - Gemfile.lock
50
52
  - LICENSE.txt
51
53
  - README.md
52
54
  - Rakefile
@@ -56,13 +58,13 @@ files:
56
58
  - lib/h2o-configurator/builder.rb
57
59
  - lib/h2o-configurator/handlers/auto-extension.rb
58
60
  - lib/h2o-configurator/handlers/redirect.rb
59
- - lib/h2o-configurator/site.rb
61
+ - lib/h2o-configurator/host.rb
60
62
  - lib/h2o-configurator/version.rb
61
63
  homepage: https://github.com/jslabovitz/h2o-configurator
62
64
  licenses:
63
65
  - MIT
64
66
  metadata: {}
65
- post_install_message:
67
+ post_install_message:
66
68
  rdoc_options: []
67
69
  require_paths:
68
70
  - lib
@@ -77,9 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
79
  - !ruby/object:Gem::Version
78
80
  version: '0'
79
81
  requirements: []
80
- rubyforge_project:
81
- rubygems_version: 2.7.4
82
- signing_key:
82
+ rubygems_version: 3.2.3
83
+ signing_key:
83
84
  specification_version: 4
84
85
  summary: Build H2O config files.
85
86
  test_files: []