This repository was archived by the owner on Jul 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Example VHost Config
johnbintz edited this page Sep 14, 2010
·
1 revision
local_config = {
:development => {
:adapter => [ '1.2.3.4:80' ],
:hostname => %w{devsite.cool.wow},
:document_root => '/var/www/devsite',
:log_dir => 'devsite',
},
:production => {
:adapter => [ '2.3.4.5:80' ],
:hostname => %w{site.cool.wow},
:document_root => '/var/www/site',
:log_dir => 'site',
}
}[APACHE_ENV]
Apache::Config.build_if('sites-available/site.conf', :development, :production) do
listen *local_config[:adapter]
virtual_host *local_config[:adapter] do
host_basics local_config
header! :unset, 'ETag'
file_etag :none
error_document! '404', '/404-haiku.html'
enable_rewrite_engine :log_level => 1
rotate_rewrite_log File.join(CONFIG[:logs_dir], local_config[:log_dir], 'rewrite.%Y%m%d%H%M'), 604800
rewrites do
rule %r{\.inc$}, '-', :forbidden => true
rewrite_test '/test.inc', :http_forbidden
end
rewrites "Bunch of old content" do
r301 %r{^/old(.*)}, '/new$1'
r301 %r{^/older(.*)}, '/newer$1'
needs_tests
end
rewrites "Special Feature" do
cond_not_a_file
cond "%{REQUEST_FILENAME}", '!(audio|downloads|graphics|images)'
rule %r{^/special-feature}, '/redirect-here#with_an_anchor', :no_escape => true, :redirect => :permanent
end
add_charset! 'UTF-8', '.xml'
directory '/' do
allow_override :all
options :exec_cgi, :follow_sym_links, :includes, :indexes
directory_index! *(%w{php shtml html cgi}.collect { |e| "index.#{e}" })
end
location '/protected' do
deny_from_all
basic_authentication "Protected Area", '/etc/apache2/users/global.users', :user => 'youcangetin'
allow_from CONFIG[:internal_subnet]
satisfy :any
end
location '/protected/graphics' do
allow_from_all
satisfy :any
end
end
end