28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/bonethug/configurator.rb', line 28
def self.vhost(vh_cnf, base_path, is_remote = false)
server_aliases = ''
aliases = vh_cnf.get('server_aliases')
if aliases
aliases.each do |index, server_alias|
server_aliases += 'ServerAlias ' + server_alias + "\n"
end
end
env_vars = ''
vars = vh_cnf.get('env_vars')
if vars
vars.each do |k, v|
env_vars += 'SetEnv ' + k + ' ' + v + "\n"
end
end
admin = vh_cnf.get('server_admin')
server_admin = admin ? 'ServerAdmin ' + admin : ''
shared_path = is_remote ? '/shared' : ''
current_path = is_remote ? '/current' : ''
case vh_cnf.get('type')
when "nginx"
vh = ""
else
access = vh_cnf.get('version').to_f >= 2.4 ? "Require all granted" : "Order allow,deny\nAllow from all"
vh = "
<VirtualHost *:80>
ServerName #{vh_cnf.get('server_name')}
#{server_aliases}
#{server_admin}
DocumentRoot #{base_path + current_path}/public
#{env_vars}
PassEnv PATH
CustomLog #{base_path + shared_path}/log/bytes.log bytes
CustomLog #{base_path + shared_path}/log/combined.log combined
ErrorLog #{base_path + shared_path}/log/error.log
<Directory #{base_path + current_path}/public>
Options Indexes MultiViews FollowSymLinks
AllowOverride All
#{access}
</Directory>
</VirtualHost>
"
end
vh
end
|