Skip to content

Commit

Permalink
Merge pull request #811 from mhaskel/693-rebase
Browse files Browse the repository at this point in the history
693 rebase
  • Loading branch information
Ashley Penney committed Aug 7, 2014
2 parents 1f8a39b + 70934a4 commit 70ccfdf
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1594,6 +1594,31 @@ Sets the value for the [PassengerEnabled](http://www.modrails.com/documentation/

`php_admin_value` sets the value of the directory, and `php_admin_flag` uses a boolean to configure the directory. Further information can be found [here](http://php.net/manual/en/configuration.changes.php).

######`rewrites`

Creates URL [`rewrites`](#rewrites) rules in vhost directories. Expects an array of hashes, and the hash keys can be any of 'comment', 'rewrite_base', 'rewrite_cond', or 'rewrite_rule'.

```puppet
apache::vhost { 'secure.example.net':
docroot => '/path/to/directory',
directories => [
{ path => '/path/to/directory',
rewrites => [ { comment => 'Permalink Rewrites',
rewrite_base => '/'
},
{ rewrite_rule => [ '^index\.php$ - [L]' ]
},
{ rewrite_cond => [ '%{REQUEST_FILENAME} !-f',
'%{REQUEST_FILENAME} !-d',
],
rewrite_rule => [ '. /index.php [L]' ],
}
],
},
],
}
```

######`ssl_options`

String or list of [SSLOptions](https://httpd.apache.org/docs/current/mod/mod_ssl.html#ssloptions), which configure SSL engine run-time options. This handler takes precedence over SSLOptions set in the parent block of the vhost.
Expand Down
39 changes: 39 additions & 0 deletions spec/acceptance/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,45 @@ class { 'apache': }
end
end

describe 'directory rewrite rules' do
it 'applies cleanly' do
pp = <<-EOS
class { 'apache': }
host { 'test.server': ip => '127.0.0.1' }
apache::vhost { 'test.server':
docroot => '/tmp',
directories => [
{
path => '/tmp',
rewrites => [
{
comment => 'Permalink Rewrites',
rewrite_base => '/',
},
{ rewrite_rule => [ '^index\.php$ - [L]' ] },
{ rewrite_cond => [
'%{REQUEST_FILENAME} !-f',
'%{REQUEST_FILENAME} !-d', ], rewrite_rule => [ '. /index.php [L]' ], }
],
},
],
}
EOS
apply_manifest(pp, :catch_failures => true)
end

describe file("#{$vhost_dir}/25-test.server.conf") do
it { should be_file }
it { should contain '#Permalink Rewrites' }
it { should contain 'RewriteEngine On' }
it { should contain 'RewriteBase /' }
it { should contain 'RewriteRule ^index\.php$ - [L]' }
it { should contain 'RewriteCond %{REQUEST_FILENAME} !-f' }
it { should contain 'RewriteCond %{REQUEST_FILENAME} !-d' }
it { should contain 'RewriteRule . /index.php [L]' }
end
end

describe 'setenv/setenvif' do
it 'applies cleanly' do
pp = <<-EOS
Expand Down
68 changes: 68 additions & 0 deletions spec/defines/vhost_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,40 @@
/^ <\/Directory>$/,
],
},
{
:title => 'should accept directory directives with rewrites array',
:attr => 'directories',
:value => [
{
'path' => '/opt/app3',
'rewrites' => [
{
'comment' => 'Permalink Rewrites',
'rewrite_base' => '/',
'rewrite_rule' => [ '^index\.php$ - [L]' ],
},
{
'rewrite_cond' => [
'%{REQUEST_FILENAME} !-f',
'%{REQUEST_FILENAME} !-d',
],
'rewrite_rule' => [ '. /index.php [L]' ],
}
]
}
],
:match => [
/^ <Directory "\/opt\/app3">$/,
/^ #Permalink Rewrites$/,
/^ RewriteEngine On$/,
/^ RewriteBase \/$/,
/^ RewriteRule \^index\\.php\$ - \[L\]$/,
/^ RewriteCond %{REQUEST_FILENAME} !-f$/,
/^ RewriteCond %{REQUEST_FILENAME} !-d$/,
/^ RewriteRule . \/index.php \[L\]$/,
/^ <\/Directory>$/,
],
},
{
:title => 'should accept location for provider',
:attr => 'directories',
Expand Down Expand Up @@ -946,6 +980,40 @@
/^ <\/Directory>$/,
],
},
{
:title => 'should accept directory directives with rewrites array',
:attr => 'directories',
:value => [
{
'path' => '/opt/app3',
'rewrites' => [
{
'comment' => 'Permalink Rewrites',
'rewrite_base' => '/',
'rewrite_rule' => [ '^index\.php$ - [L]' ],
},
{
'rewrite_cond' => [
'%{REQUEST_FILENAME} !-f',
'%{REQUEST_FILENAME} !-d',
],
'rewrite_rule' => [ '. /index.php [L]' ],
}
]
}
],
:match => [
/^ <Directory "\/opt\/app3">$/,
/^ #Permalink Rewrites$/,
/^ RewriteEngine On$/,
/^ RewriteBase \/$/,
/^ RewriteRule \^index\\.php\$ - \[L\]$/,
/^ RewriteCond %{REQUEST_FILENAME} !-f$/,
/^ RewriteCond %{REQUEST_FILENAME} !-d$/,
/^ RewriteRule . \/index.php \[L\]$/,
/^ <\/Directory>$/,
],
},
{
:title => 'should accept location for provider',
:attr => 'directories',
Expand Down
24 changes: 24 additions & 0 deletions templates/vhost/_directories.erb
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,30 @@
<%- if directory['fcgiwrapper'] -%>
FcgidWrapper <%= directory['fcgiwrapper']['command'] %> <%= directory['fcgiwrapper']['suffix'] %> <%= directory['fcgiwrapper']['virtual'] %>
<%- end -%>
<%- if directory['rewrites'] -%>
# Rewrite rules
RewriteEngine On
<%- directory['rewrites'].flatten.compact.each do |rewrite_details| -%>
<%- if rewrite_details['comment'] -%>
#<%= rewrite_details['comment'] %>
<%- end -%>
<%- if rewrite_details['rewrite_base'] -%>
RewriteBase <%= rewrite_details['rewrite_base'] %>
<%- end -%>
<%- if rewrite_details['rewrite_cond'] -%>
<%- Array(rewrite_details['rewrite_cond']).each do |commands| -%>
<%- Array(commands).each do |command| -%>
RewriteCond <%= command %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- Array(rewrite_details['rewrite_rule']).each do |commands| -%>
<%- Array(commands).each do |command| -%>
RewriteRule <%= command %>
<%- end -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%- if directory['custom_fragment'] -%>
<%= directory['custom_fragment'] %>
<%- end -%>
Expand Down

0 comments on commit 70ccfdf

Please sign in to comment.