Skip to content

Commit

Permalink
Merge pull request #1228 from bryangwilliam/absolute_redirect
Browse files Browse the repository at this point in the history
add absolute_redirect support
  • Loading branch information
bastelfreak authored Jul 8, 2018
2 parents 348dcc4 + d0a8166 commit 0ef72eb
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
$super_user = $nginx::super_user
$temp_dir = $nginx::temp_dir
$server_purge = $nginx::server_purge
$absolute_redirect = $nginx::absolute_redirect
$accept_mutex = $nginx::accept_mutex
$accept_mutex_delay = $nginx::accept_mutex_delay
$client_body_buffer_size = $nginx::client_body_buffer_size
Expand Down
1 change: 1 addition & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
$conf_template = 'nginx/conf.d/nginx.conf.erb',

### START Nginx Configuration ###
Optional[Enum['on', 'off']] $absolute_redirect = undef,
$accept_mutex = 'on',
$accept_mutex_delay = '500ms',
$client_body_buffer_size = '128k',
Expand Down
2 changes: 2 additions & 0 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
# [*proxy_set_body*] - If defined, sets the body passed to the backend.
# [*proxy_buffering*] - If defined, sets the proxy_buffering to the passed
# value.
# [*absolute_redirect*] - Enables or disables the absolute redirect functionality of nginx
# [*auth_basic*] - This directive includes testing name and password
# with HTTP Basic Authentication.
# [*auth_basic_user_file*] - This directive sets the htpasswd filename for
Expand Down Expand Up @@ -216,6 +217,7 @@
Optional[String] $proxy_http_version = undef,
Optional[String] $proxy_set_body = undef,
Optional[Enum['on', 'off']] $proxy_buffering = undef,
Optional[Enum['on', 'off']] $absolute_redirect = undef,
Optional[String] $auth_basic = undef,
Optional[String] $auth_basic_user_file = undef,
Optional[String] $auth_request = undef,
Expand Down
2 changes: 2 additions & 0 deletions manifests/resource/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
# [*proxy_method*] - If defined, overrides the HTTP method of the request to be passed to the backend.
# [*proxy_http_version*] - Sets the proxy http version
# [*proxy_set_body*] - If defined, sets the body passed to the backend.
# [*absolute_redirect*] - Enables or disables the absolute redirect functionality of nginx
# [*auth_basic*] - This directive includes testing name and password with HTTP Basic Authentication.
# [*auth_basic_user_file*] - This directive sets the htpasswd filename for the authentication realm.
# [*auth_request*] - This allows you to specify a custom auth endpoint
Expand Down Expand Up @@ -225,6 +226,7 @@
Optional[Hash] $location_custom_cfg_prepend = undef,
Optional[Hash] $location_custom_cfg_append = undef,
Optional[Array[String]] $try_files = undef,
Optional[Enum['on', 'off']] $absolute_redirect = undef,
Optional[String] $auth_basic = undef,
Optional[String] $auth_basic_user_file = undef,
Optional[String] $auth_request = undef,
Expand Down
12 changes: 12 additions & 0 deletions spec/classes/nginx_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,18 @@
value: false,
notmatch: %r{pid}
},
{
title: 'should not set absolute_redirect',
attr: 'absolute_redirect',
value: :undef,
notmatch: %r{absolute_redirect}
},
{
title: 'should set absolute_redirect off',
attr: 'absolute_redirect',
value: 'off',
match: ' absolute_redirect off;'
},
{
title: 'should set accept_mutex on',
attr: 'accept_mutex',
Expand Down
12 changes: 12 additions & 0 deletions spec/defines/resource_location_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@
value: [],
notmatch: %r{rewrite}
},
{
title: 'should not set absolute_redirect',
attr: 'absolute_redirect',
value: :undef,
notmatch: %r{absolute_redirect}
},
{
title: 'should set absolute_redirect off',
attr: 'absolute_redirect',
value: 'off',
match: ' absolute_redirect off;'
},
{
title: 'should set auth_basic',
attr: 'auth_basic',
Expand Down
24 changes: 24 additions & 0 deletions spec/defines/resource_server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,18 @@
value: false,
match: %r{\s+server_name\s+www.rspec.example.com;}
},
{
title: 'should not set absolute_redirect',
attr: 'absolute_redirect',
value: :undef,
notmatch: %r{absolute_redirect}
},
{
title: 'should set absolute_redirect off',
attr: 'absolute_redirect',
value: 'off',
match: ' absolute_redirect off;'
},
{
title: 'should set auth_basic',
attr: 'auth_basic',
Expand Down Expand Up @@ -663,6 +675,18 @@
value: 'off',
match: %r{\s+ssl_prefer_server_ciphers\s+off;}
},
{
title: 'should not set absolute_redirect',
attr: 'absolute_redirect',
value: :undef,
notmatch: %r{absolute_redirect}
},
{
title: 'should set absolute_redirect off',
attr: 'absolute_redirect',
value: 'off',
match: ' absolute_redirect off;'
},
{
title: 'should set auth_basic',
attr: 'auth_basic',
Expand Down
3 changes: 3 additions & 0 deletions templates/conf.d/nginx.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ http {
<% end -%>
<% end -%>

<% if @absolute_redirect -%>
absolute_redirect <%= @absolute_redirect %>;
<% end -%>
<% if @http_access_log.is_a?(Array) -%>
<%- @http_access_log.each do |log_item| -%>
access_log <%= log_item %><% if @http_format_log %> <%= @http_format_log%><% end %>;
Expand Down
3 changes: 3 additions & 0 deletions templates/server/location_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
deny <%= deny_rule %>;
<%- end -%>
<% end -%>
<% if @absolute_redirect -%>
absolute_redirect <%= @absolute_redirect %>;
<% end -%>
<% if @auth_basic -%>
auth_basic "<%= @auth_basic %>";
<% end -%>
Expand Down
3 changes: 3 additions & 0 deletions templates/server/server_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ server {
<% if defined? @log_by_lua_file -%>
log_by_lua_file "<%= @log_by_lua_file %>";
<% end -%>
<% if @absolute_redirect -%>
absolute_redirect <%= @absolute_redirect %>;
<% end -%>
<% if @access_log.is_a?(Array) -%>
<%- @access_log.each do |log_item| -%>
access_log <%= log_item %> <%= @format_log %>;
Expand Down
3 changes: 3 additions & 0 deletions templates/server/server_ssl_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ server {
index <% Array(@index_files).each do |i| %> <%= i %><% end %>;

<% end -%>
<% if @absolute_redirect -%>
absolute_redirect <%= @absolute_redirect %>;
<% end -%>
<% if @access_log.is_a?(Array) -%>
<%- @access_log.each do |log_item| -%>
access_log <%= log_item %> <%= @format_log %>;
Expand Down

0 comments on commit 0ef72eb

Please sign in to comment.