apache-config-generator 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,5 @@
1
+ v0.1.2. Some more small fixes.
2
+
1
3
  v0.1.1. Stupid bug in initial release.
2
4
 
3
5
  v0.1. Initial release, support for many of the Apache config basics.
data/Manifest CHANGED
@@ -1,6 +1,5 @@
1
1
  CHANGELOG
2
- Manifest
3
- README.md
2
+ README.rdoc
4
3
  Rakefile
5
4
  bin/apache-configurator
6
5
  lib/apache.rb
@@ -18,3 +17,4 @@ lib/apache/rewrites.rb
18
17
  lib/apache/ssl.rb
19
18
  skel/Rakefile
20
19
  skel/config.yml
20
+ Manifest
@@ -0,0 +1,34 @@
1
+ = Apache Config Generator
2
+
3
+ Programmatically construct your Apache configuration using a powerful DSL built in Ruby.
4
+
5
+ == Installation
6
+
7
+ <tt>gem install apache-config-generator</tt>
8
+
9
+ == Usage
10
+
11
+ Run <tt>apache-configurator <directory></tt> to create a new directory to hold your config files.
12
+ A Rakefile and config.yml file will also be generated.
13
+
14
+ == Building a config file
15
+
16
+ Configs center around the Apache::Config.build method:
17
+
18
+ Apache::Config.build('sites-available/my-site.conf') do
19
+ server_name 'my-cool-website.cool.wow'
20
+ document_root '/var/www/my-cool-website'
21
+
22
+ directory '/' do
23
+ options :follow_sym_links, :indexes
24
+ allow_from_all
25
+ end
26
+
27
+ location_match %r{^/secret} do
28
+ deny_from_all
29
+
30
+ basic_authentication "My secret", '/etc/apache2/users/global.users', :user => :john
31
+ satisfy :any
32
+ end
33
+ end
34
+
data/Rakefile CHANGED
@@ -20,6 +20,7 @@ Echoe.new('apache-config-generator') do |p|
20
20
  p.summary = "A Ruby DSL for programmatically generating Apache configs"
21
21
  p.ignore_pattern = [ 'spec/**/*', 'test/**/*', 'docs/**/*' ]
22
22
  p.executable_pattern = [ 'bin/**/*' ]
23
+ p.runtime_dependencies = [ 'rainbow' ]
23
24
  end
24
25
 
25
26
  namespace :spec do
@@ -34,6 +35,7 @@ end
34
35
 
35
36
  Rake::RDocTask.new do |rdoc|
36
37
  rdoc.template = 'direct'
37
- rdoc.rdoc_files.add('lib')
38
+ rdoc.rdoc_files.add('lib', 'README.rdoc')
39
+ rdoc.main = 'README.rdoc'
38
40
  rdoc.rdoc_dir = 'docs'
39
41
  end
@@ -2,19 +2,19 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{apache-config-generator}
5
- s.version = "0.1.1"
5
+ s.version = "0.1.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["John Bintz"]
9
- s.date = %q{2010-05-10}
9
+ s.date = %q{2010-05-12}
10
10
  s.default_executable = %q{apache-configurator}
11
11
  s.description = %q{A Ruby DSL for programmatically generating Apache configs}
12
12
  s.email = %q{}
13
13
  s.executables = ["apache-configurator"]
14
- s.extra_rdoc_files = ["CHANGELOG", "README.md", "bin/apache-configurator", "lib/apache.rb", "lib/apache/config.rb", "lib/apache/directory.rb", "lib/apache/logging.rb", "lib/apache/master.rb", "lib/apache/modules.rb", "lib/apache/mpm_prefork.rb", "lib/apache/performance.rb", "lib/apache/permissions.rb", "lib/apache/quoteize.rb", "lib/apache/rake/create.rb", "lib/apache/rewrites.rb", "lib/apache/ssl.rb"]
15
- s.files = ["CHANGELOG", "Manifest", "README.md", "Rakefile", "bin/apache-configurator", "lib/apache.rb", "lib/apache/config.rb", "lib/apache/directory.rb", "lib/apache/logging.rb", "lib/apache/master.rb", "lib/apache/modules.rb", "lib/apache/mpm_prefork.rb", "lib/apache/performance.rb", "lib/apache/permissions.rb", "lib/apache/quoteize.rb", "lib/apache/rake/create.rb", "lib/apache/rewrites.rb", "lib/apache/ssl.rb", "skel/Rakefile", "skel/config.yml", "apache-config-generator.gemspec"]
14
+ s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "bin/apache-configurator", "lib/apache.rb", "lib/apache/config.rb", "lib/apache/directory.rb", "lib/apache/logging.rb", "lib/apache/master.rb", "lib/apache/modules.rb", "lib/apache/mpm_prefork.rb", "lib/apache/performance.rb", "lib/apache/permissions.rb", "lib/apache/quoteize.rb", "lib/apache/rake/create.rb", "lib/apache/rewrites.rb", "lib/apache/ssl.rb"]
15
+ s.files = ["CHANGELOG", "README.rdoc", "Rakefile", "bin/apache-configurator", "lib/apache.rb", "lib/apache/config.rb", "lib/apache/directory.rb", "lib/apache/logging.rb", "lib/apache/master.rb", "lib/apache/modules.rb", "lib/apache/mpm_prefork.rb", "lib/apache/performance.rb", "lib/apache/permissions.rb", "lib/apache/quoteize.rb", "lib/apache/rake/create.rb", "lib/apache/rewrites.rb", "lib/apache/ssl.rb", "skel/Rakefile", "skel/config.yml", "Manifest", "apache-config-generator.gemspec"]
16
16
  s.homepage = %q{}
17
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Apache-config-generator", "--main", "README.md"]
17
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Apache-config-generator", "--main", "README.rdoc"]
18
18
  s.require_paths = ["lib"]
19
19
  s.rubyforge_project = %q{apache-config-generator}
20
20
  s.rubygems_version = %q{1.3.6}
@@ -25,8 +25,11 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 3
26
26
 
27
27
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<rainbow>, [">= 0"])
28
29
  else
30
+ s.add_dependency(%q<rainbow>, [">= 0"])
29
31
  end
30
32
  else
33
+ s.add_dependency(%q<rainbow>, [">= 0"])
31
34
  end
32
35
  end
@@ -1,4 +1,5 @@
1
1
  require 'fileutils'
2
+ require 'rainbow'
2
3
 
3
4
  Dir[File.join(File.dirname(__FILE__), '*.rb')].each { |f| require f }
4
5
 
@@ -62,6 +63,7 @@ module Apache
62
63
  include Apache::Performance
63
64
  include Apache::Rewrites
64
65
  include Apache::MPM
66
+ include Apache::SSL
65
67
 
66
68
  # Build the provided configuration only if the current environment matches one of the conditions
67
69
  def build_if(target, *conditions, &block)
@@ -123,7 +125,9 @@ module Apache
123
125
  def apachify(name)
124
126
  case name
125
127
  when String, Symbol
126
- name.to_s.split("_").collect(&:capitalize).join.gsub('Ssl', 'SSL').gsub('Cgi', 'CGI').gsub('Ldap', 'LDAP').gsub('Url', 'URL')
128
+ name.to_s.split("_").collect(&:capitalize).join.gsub('Ssl', 'SSL').
129
+ gsub('Cgi', 'CGI').gsub('Ldap', 'LDAP').gsub('Url', 'URL').
130
+ gsub('Etag', 'ETag')
127
131
  when Array
128
132
  name.collect { |n| apachify(n) }
129
133
  end
@@ -229,17 +233,21 @@ module Apache
229
233
  "|#{@rotate_logs_path} #{path} #{time}"
230
234
  end
231
235
 
236
+ def warn_msg(from, color = :red)
237
+ "[warn::#{from}]".foreground(color)
238
+ end
239
+
232
240
  private
233
241
  def writable?(path)
234
- puts "[warn] #{path} may not be writable!" if !File.directory? File.split(path).first
242
+ puts " #{warn_msg('writable?')} #{path.foreground(:yellow)} may not be writable!" if !File.directory? File.split(path).first
235
243
  end
236
244
 
237
245
  def directory?(path)
238
- puts "[warn] #{path} does not exist!" if !File.directory? path
246
+ puts " #{warn_msg('directory?')} #{path.foreground(:yellow)} does not exist!" if !File.directory? path
239
247
  end
240
248
 
241
249
  def exist?(path)
242
- puts "[warn] #{path} does not exist!" if !File.exist?(path)
250
+ puts " #{warn_msg('exist?')} #{path.foreground(:yellow)} does not exist!" if !File.exist?(path)
243
251
  end
244
252
  end
245
253
 
@@ -19,7 +19,20 @@ module Apache
19
19
 
20
20
  private
21
21
  def create_options_list(tag, *opt)
22
- self << "#{tag} #{apachify(opt) * " "}"
22
+ opt = opt.collect do |o|
23
+ case o
24
+ when Symbol
25
+ if o.to_s[0..3] == 'not_'
26
+ "-#{apachify(o.to_s[4..-1])}"
27
+ else
28
+ apachify(o)
29
+ end
30
+ else
31
+ apachify(o)
32
+ end
33
+ end
34
+
35
+ self << "#{tag} #{opt * " "}"
23
36
  end
24
37
  end
25
38
  end
@@ -8,6 +8,11 @@ module Apache
8
8
  @config += Modules.build(*modules, &block)
9
9
  end
10
10
 
11
+ def listen(*opt)
12
+ opt.each { |o| self << "Listen #{quoteize(o)}" }
13
+ end
14
+ alias :listen! :listen
15
+
11
16
  # Add a User/Group block
12
17
  # runner('www', 'www-data') #=>
13
18
  # User www
@@ -101,5 +106,12 @@ module Apache
101
106
  self << output
102
107
  end
103
108
  end
109
+
110
+ def server_name(*opts)
111
+ if first = opts.shift
112
+ self << "ServerName #{quoteize(first)}"
113
+ opts.each { |o| server_alias o } if !opts.empty?
114
+ end
115
+ end
104
116
  end
105
117
  end
@@ -85,7 +85,7 @@ module Apache
85
85
  # Create an Apache require directive.
86
86
  # Used to get around Ruby reserved word.
87
87
  def apache_require(*opts)
88
- self << "Require #{opts * " "}"
88
+ self << "Require #{opts.compact * " "}"
89
89
  end
90
90
  end
91
91
  end
@@ -2,6 +2,7 @@ require 'fileutils'
2
2
  require 'apache/config'
3
3
  require 'apache/rake/create'
4
4
  require 'yaml'
5
+ require 'rainbow'
5
6
 
6
7
  namespace :apache do
7
8
  desc "Create all defined configs for the specified environment"
@@ -19,7 +20,7 @@ namespace :apache do
19
20
  Dir.chdir CONFIG[:dest_path]
20
21
 
21
22
  Dir[File.join(CONFIG[:source_path], '**', '*.rb')].each do |file|
22
- puts file
23
+ puts file.foreground(:green)
23
24
  require file
24
25
  end
25
26
  end
@@ -1,3 +1,5 @@
1
+ require 'pp'
2
+
1
3
  module Apache
2
4
  # Handle the creation of RewriteRules, RewriteConds, Redirects, and RedirectMatches
3
5
  module Rewrites
@@ -6,7 +8,7 @@ module Apache
6
8
  # enable_rewrite_engine :log_level => 1 #=>
7
9
  # RewriteEngine on
8
10
  # RewriteLogLevel 1
9
- def enable_rewrite_engine(options)
11
+ def enable_rewrite_engine(options = {})
10
12
  self << ''
11
13
  rewrite_engine! :on
12
14
  options.each do |option, value|
@@ -19,15 +21,22 @@ module Apache
19
21
  end
20
22
 
21
23
  # Pass the block to RewriteManager.build
22
- def rewrites(&block)
23
- self + indent(RewriteManager.build(&block))
24
+ def rewrites(*opt, &block)
25
+ self + indent(RewriteManager.build(*opt, &block))
24
26
  self << ''
25
27
  end
26
28
 
29
+ def rewrite(*opt, &block)
30
+ raise "You probably want rewrites #{quoteize(*opt) * " "} do" if block
31
+ end
32
+
27
33
  # Create a permanent Redirect
28
34
  #
29
35
  # r301 '/here', '/there' #=> Redirect permanent "/here" "/there"
30
36
  def r301(*opt)
37
+ if opt.first && !opt.first.kind_of?(::String)
38
+ raise "First parameter should be a String. Did you mean to wrap this in a rewrites block? #{opt.first}"
39
+ end
31
40
  self << "Redirect permanent #{quoteize(*opt) * " "}"
32
41
  end
33
42
  end
@@ -43,12 +52,27 @@ module Apache
43
52
  end
44
53
 
45
54
  # Build rewritable things from the provided block
46
- def build(&block)
55
+ def build(*opt, &block)
47
56
  reset!
48
57
 
58
+ @any_tests = false
59
+ @needs_tests = false
49
60
  self.instance_eval(&block)
50
61
 
51
- @rewrites.collect(&:to_a).flatten
62
+ name = opt.first || (@rewrites.empty? ? 'unnamed block' : "#{@rewrites.first.from} => #{@rewrites.first.to}")
63
+
64
+ if !@any_tests && !@rewrites.empty?
65
+ puts " [#{"rewrite".foreground(:blue)}] no tests found for #{name}"
66
+ end
67
+
68
+ if @needs_tests
69
+ puts " [#{"rewrite".foreground(:blue)}] #{name} needs more tests"
70
+ end
71
+
72
+ output = @rewrites.collect(&:to_a).flatten
73
+ output.unshift("# #{name}") if opt.first
74
+
75
+ output
52
76
  end
53
77
 
54
78
  # Commit the latest rewritable thing to the list of rewrites
@@ -96,16 +120,49 @@ module Apache
96
120
 
97
121
  # Test the rewritable things defined in this block
98
122
  def rewrite_test(from, to, opts = {})
123
+ @any_tests = true
99
124
  orig_from = from.dup
100
125
  @rewrites.each do |r|
101
- from = r.test(from, opts)
126
+ pre_from = from.dup
127
+ if r.match?(from, opts)
128
+ from = r.test(from, opts)
129
+ from = pre_from if (r.to == '-')
130
+ from = :http_forbidden if (r.forbidden?)
131
+ break if r.stop_if_match?
132
+ end
102
133
  end
103
134
 
104
135
  if from != to
105
- puts "[warn] #{orig_from} >> #{to} failed!"
106
- puts "[warn] Result: #{from}"
136
+ puts " [#{"rewrite".foreground(:blue)}] #{orig_from} >> #{to} failed!"
137
+ puts " [#{"rewrite".foreground(:blue)}] Result: #{from}"
107
138
  end
108
139
  end
140
+
141
+ def needs_tests
142
+ @needs_tests = true
143
+ end
144
+
145
+ def cond_not_a_file(opts = {})
146
+ cond_file_flag '!-f', opts
147
+ end
148
+
149
+ def cond_is_a_file(opts = {})
150
+ cond_file_flag '-f', opts
151
+ end
152
+
153
+ def cond_not_a_directory(opts = {})
154
+ cond_file_flag '!-d', opts
155
+ end
156
+
157
+ def cond_is_a_directory(opts = {})
158
+ cond_file_flag '-d', opts
159
+ end
160
+
161
+ private
162
+ def cond_file_flag(flag, opts)
163
+ cond opts[:filename_only] ? "%{REQUEST_FILENAME}" : "%{DOCUMENT_ROOT}%{REQUEST_FILENAME}", flag
164
+ end
165
+
109
166
  end
110
167
  end
111
168
 
@@ -117,6 +174,10 @@ module Apache
117
174
  replace_placeholders(from, opts)
118
175
  end
119
176
 
177
+ def match?(from, opts = {})
178
+ replace_placeholders(from, opts)[@from]
179
+ end
180
+
120
181
  # Replace the placeholders in this rewritable thing
121
182
  def replace_placeholders(s, opts)
122
183
  opts.each do |opt, value|
@@ -125,7 +186,7 @@ module Apache
125
186
  s = s.gsub('%{' + opt.to_s.upcase + '}', value)
126
187
  end
127
188
  end
128
- s
189
+ s.gsub(%r{%\{[^\}]+\}}, '')
129
190
  end
130
191
  end
131
192
 
@@ -133,6 +194,8 @@ module Apache
133
194
  class MatchableThing
134
195
  include Apache::Quoteize
135
196
 
197
+ attr_reader :from, :to
198
+
136
199
  # The Apache directive tag for this thing
137
200
  def tag; raise 'Override this method'; end
138
201
 
@@ -153,6 +216,9 @@ module Apache
153
216
  def to_a
154
217
  [ to_s ]
155
218
  end
219
+
220
+ def stop_if_match?; false; end
221
+ def forbidden?; false; end
156
222
  end
157
223
 
158
224
  # A RewriteRule definition
@@ -165,24 +231,37 @@ module Apache
165
231
  super
166
232
  @conditions = []
167
233
  @options = nil
234
+ @input_options = {}
168
235
  end
169
236
 
170
237
  # Define the rule, passing in additional options
171
238
  #
172
239
  # rule %r{^/here}, '/there', { :last => true, :preserve_query_string => true }
173
- def rule(from, to,options = {})
240
+ def rule(from, to, options = {})
174
241
  super(from, to)
175
242
 
176
243
  raise "from must be a Regexp" if !from.kind_of?(Regexp)
177
244
 
245
+ @input_options = options
246
+
178
247
  options = options.collect do |key, value|
179
248
  case key
180
249
  when :last
181
250
  'L'
182
- when :preserve_query_string
251
+ when :forbidden
252
+ 'F'
253
+ when :no_escape
254
+ 'NE'
255
+ when :redirect
256
+ (value == true) ? 'R' : "R=#{value}"
257
+ when :pass_through
258
+ 'PT'
259
+ when :preserve_query_string, :query_string_append
183
260
  'QSA'
261
+ when :env
262
+ "E=#{value}"
184
263
  end
185
- end.sort
264
+ end.compact.sort
186
265
 
187
266
  @options = !options.empty? ? "[#{options * ','}]" : nil
188
267
  end
@@ -200,12 +279,23 @@ module Apache
200
279
  end
201
280
 
202
281
  def to_a
203
- [ @conditions.collect(&:to_s), super ].flatten
282
+ [ ('' if !@conditions.empty?), @conditions.collect(&:to_s), super ].flatten
204
283
  end
205
284
 
206
285
  # Test this RewriteRule, ensuring the RewriteConds also match
207
286
  def test(from, opts = {})
287
+ opts[:request_uri] = from
288
+ result = from
289
+
290
+ result = super(from, opts) if match?(from, opts)
291
+
292
+ replace_placeholders(result, opts)
293
+ end
294
+
295
+ def match?(from, opts = {})
296
+ opts[:request_uri] = from
208
297
  ok = true
298
+
209
299
  @conditions.each do |c|
210
300
  ok = false if !c.test(from, opts)
211
301
  end
@@ -213,9 +303,17 @@ module Apache
213
303
  if ok
214
304
  super(from, opts)
215
305
  else
216
- replace_placeholders(from, opts)
306
+ false
217
307
  end
218
308
  end
309
+
310
+ def stop_if_match?
311
+ @input_options[:last]
312
+ end
313
+
314
+ def forbidden?
315
+ @input_options[:forbidden]
316
+ end
219
317
  end
220
318
 
221
319
  # A permanent RedirectMatch
@@ -233,6 +331,8 @@ module Apache
233
331
  def to_s
234
332
  "#{tag} #{[quoteize(@from.source), quoteize(@to)].compact.flatten * " "}"
235
333
  end
334
+
335
+ def stop_if_match; true; end
236
336
  end
237
337
 
238
338
  # A RewriteCond
@@ -278,20 +378,26 @@ module Apache
278
378
  super(from, opts)
279
379
  source = replace_placeholders(@from, opts)
280
380
 
381
+ to = @to
382
+ reverse = false
383
+
384
+ if @to[0..0] == '!'
385
+ reverse = true
386
+ to = @to[1..-1]
387
+ end
388
+
281
389
  result = false
282
- case @to[0..0]
283
- when '!'
284
- result = !source[Regexp.new(@to[1..-1])]
390
+ case to[0..0]
285
391
  when '-'
286
- case @to
392
+ case to
287
393
  when '-f'
288
394
  result = opts[:files].include? source if opts[:files]
289
395
  end
290
396
  else
291
- result = source[Regexp.new(@to)]
397
+ result = source[Regexp.new(to)]
292
398
  end
293
399
 
294
- result
400
+ reverse ? !result : result
295
401
  end
296
402
  end
297
403
  end
@@ -0,0 +1,17 @@
1
+ module Apache
2
+ module SSL
3
+ def enable_ssl_engine(options = {})
4
+ self << ""
5
+ self << "SSLEngine on"
6
+ options.each do |k, v|
7
+ case k
8
+ when :certificate_file, :certificate_key_file
9
+ self << "SSL#{apachify(k)} #{quoteize(v).first}"
10
+ when :ca_certificate_file
11
+ self << "SSLCACertificateFile #{quoteize(v).first}"
12
+ end
13
+ end
14
+ self << ""
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 1
9
- version: 0.1.1
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Bintz
@@ -14,10 +14,21 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-10 00:00:00 -04:00
17
+ date: 2010-05-12 00:00:00 -04:00
18
18
  default_executable:
19
- dependencies: []
20
-
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rainbow
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ version: "0"
30
+ type: :runtime
31
+ version_requirements: *id001
21
32
  description: A Ruby DSL for programmatically generating Apache configs
22
33
  email: ""
23
34
  executables:
@@ -26,7 +37,7 @@ extensions: []
26
37
 
27
38
  extra_rdoc_files:
28
39
  - CHANGELOG
29
- - README.md
40
+ - README.rdoc
30
41
  - bin/apache-configurator
31
42
  - lib/apache.rb
32
43
  - lib/apache/config.rb
@@ -43,8 +54,7 @@ extra_rdoc_files:
43
54
  - lib/apache/ssl.rb
44
55
  files:
45
56
  - CHANGELOG
46
- - Manifest
47
- - README.md
57
+ - README.rdoc
48
58
  - Rakefile
49
59
  - bin/apache-configurator
50
60
  - lib/apache.rb
@@ -62,6 +72,7 @@ files:
62
72
  - lib/apache/ssl.rb
63
73
  - skel/Rakefile
64
74
  - skel/config.yml
75
+ - Manifest
65
76
  - apache-config-generator.gemspec
66
77
  has_rdoc: true
67
78
  homepage: ""
@@ -74,7 +85,7 @@ rdoc_options:
74
85
  - --title
75
86
  - Apache-config-generator
76
87
  - --main
77
- - README.md
88
+ - README.rdoc
78
89
  require_paths:
79
90
  - lib
80
91
  required_ruby_version: !ruby/object:Gem::Requirement
data/README.md DELETED
@@ -1,33 +0,0 @@
1
- # Apache Config Generator
2
-
3
- Programmatically construct your Apache configuration using a powerful DSL built in Ruby.
4
-
5
- ## Installation
6
-
7
- `gem install apache-config-generator`
8
-
9
- ## Usage
10
-
11
- Run `apache-configurator <directory>` to create a new directory to hold your config files.
12
- A Rakefile and config.yml file will also be generated.
13
-
14
- ## Building a config file
15
-
16
- Configs center around the Apache::Config.build method:
17
-
18
- Apache::Config.build('sites-available/my-site.conf') do
19
- server_name 'my-cool-website.cool.wow'
20
- document_root '/var/www/my-cool-website'
21
-
22
- directory '/' do
23
- options :follow_sym_links, :indexes
24
- allow_from_all
25
- end
26
-
27
- location_match %r{^/secret} do
28
- deny_from_all
29
-
30
- basic_authentication "My secret", '/etc/apache2/users/global.users', :user => :john
31
- satisfy :any
32
- end
33
- end