h2o-configurator 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/Gemfile.lock +21 -0
- data/bin/h2o-configurator +1 -1
- data/h2o-configurator.gemspec +1 -1
- data/lib/h2o-configurator.rb +1 -3
- data/lib/h2o-configurator/builder.rb +10 -4
- data/lib/h2o-configurator/{site.rb → host.rb} +28 -29
- data/lib/h2o-configurator/version.rb +1 -1
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1249082a62a2b5a079c0b020eb686567171128d7e890b91de8820c0af621f38
|
4
|
+
data.tar.gz: 4becf75eb92462af854556427571d5e0a387eda0444403f53a3e4d29e9bbe8a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6de83ab48209998cd51512a4ef022531df7a51f41b7b3250128a0cf99c8fbe197c5d4a7696ba0141672cdeaa230a8dfd126c7919eaa518d86607795b95fb37b
|
7
|
+
data.tar.gz: 217c7cd7bd7546cca8ca3acc28ea889d8f11d0e25acdcc3f657d196ec177de5de4077ea6f5f287a19ad57955a83083111cb187f105cd5bb5b7decd0166da97ff
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -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
|
data/bin/h2o-configurator
CHANGED
data/h2o-configurator.gemspec
CHANGED
data/lib/h2o-configurator.rb
CHANGED
@@ -2,7 +2,7 @@ require 'path'
|
|
2
2
|
require 'yaml'
|
3
3
|
|
4
4
|
require 'h2o-configurator/builder'
|
5
|
-
require 'h2o-configurator/
|
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
|
-
|
13
|
-
|
14
|
-
puts "%30s => %s" % [
|
15
|
-
config['hosts'].merge!(
|
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
|
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
|
-
|
17
|
-
|
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
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
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.
|
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:
|
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/
|
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
|
-
|
81
|
-
|
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: []
|