Fixed merge
This commit is contained in:
commit
73722c0fc6
6 changed files with 24 additions and 7 deletions
|
@ -12,6 +12,7 @@
|
|||
# with nginx::resource::upstream
|
||||
# [*proxy_read_timeout*] - Override the default the proxy read timeout value of 90 seconds
|
||||
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
|
||||
# [*location_alias*] - Path to be used as basis for serving requests for this location
|
||||
# [*option*] - Reserved for future use
|
||||
#
|
||||
# Actions:
|
||||
|
@ -34,6 +35,7 @@ define nginx::resource::location(
|
|||
$proxy = undef,
|
||||
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
|
||||
$ssl = false,
|
||||
$location_alias = undef,
|
||||
$option = undef,
|
||||
$location
|
||||
) {
|
||||
|
@ -53,6 +55,8 @@ define nginx::resource::location(
|
|||
# Use proxy template if $proxy is defined, otherwise use directory template.
|
||||
if ($proxy != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_proxy.erb')
|
||||
} elsif ($location_alias != undef) {
|
||||
$content_real = template('nginx/vhost/vhost_location_alias.erb')
|
||||
} else {
|
||||
$content_real = template('nginx/vhost/vhost_location_directory.erb')
|
||||
}
|
||||
|
@ -61,8 +65,8 @@ define nginx::resource::location(
|
|||
if ($vhost == undef) {
|
||||
fail('Cannot create a location reference without attaching to a virtual host')
|
||||
}
|
||||
if (($www_root == undef) and ($proxy == undef)) {
|
||||
fail('Cannot create a location reference without a www_root or proxy defined')
|
||||
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef)) {
|
||||
fail('Cannot create a location reference without a www_root, proxy or location_alias defined')
|
||||
}
|
||||
if (($www_root != undef) and ($proxy != undef)) {
|
||||
fail('Cannot define both directory and proxy in a virtual host')
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# [*ssl*] - Indicates whether to setup SSL bindings for this vhost.
|
||||
# [*ssl_cert*] - Pre-generated SSL Certificate file to reference for SSL Support. This is not generated by this module.
|
||||
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL Support. This is not generated by this module.
|
||||
# [*server_name*] - List of vhostnames for which this vhost will respond. Default [$name].
|
||||
# [*www_root*] - Specifies the location on disk for files to be read from. Cannot be set in conjunction with $proxy
|
||||
# [*rewrite_www_to_non_www*] - Adds a server directive and rewrite rule to rewrite www.domain.com to domain.com in order to avoid
|
||||
# duplicate content (SEO);
|
||||
|
@ -46,6 +47,7 @@ define nginx::resource::vhost(
|
|||
$proxy = undef,
|
||||
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
|
||||
$index_files = ['index.html', 'index.htm', 'index.php'],
|
||||
$server_name = [$name],
|
||||
$www_root = undef,
|
||||
$rewrite_www_to_non_www = false,
|
||||
) {
|
||||
|
|
|
@ -6,7 +6,7 @@ pid <%= scope.lookupvar('nginx::params::nx_pid')%>;
|
|||
|
||||
events {
|
||||
worker_connections <%= worker_connections %>;
|
||||
<% if scope.lookupvar('nginx::params::nx_multi_accept' == 'on') %>multi_accept on;<% end %>
|
||||
<% if scope.lookupvar('nginx::params::nx_multi_accept') == 'on' %>multi_accept on;<% end %>
|
||||
}
|
||||
|
||||
http {
|
||||
|
@ -17,17 +17,17 @@ http {
|
|||
|
||||
sendfile <%= scope.lookupvar('nginx::params::nx_sendfile')%>;
|
||||
|
||||
<% if scope.lookupvar('nginx::params::nx_tcp_nopush' == 'on') %>
|
||||
<% if scope.lookupvar('nginx::params::nx_tcp_nopush') == 'on' %>
|
||||
tcp_nopush on;
|
||||
<% end %>
|
||||
|
||||
keepalive_timeout <%= scope.lookupvar('nginx::params::nx_keepalive_timeout')%>;
|
||||
tcp_nodelay <%= scope.lookupvar('nginx::params::nx_tcp_nodelay')%>;
|
||||
|
||||
<% if scope.lookupvar('nginx::params::nx_gzip' == 'on') %>
|
||||
<% if scope.lookupvar('nginx::params::nx_gzip') == 'on' %>
|
||||
gzip on;
|
||||
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
||||
<% end %>
|
||||
|
||||
include /etc/nginx/conf.d/*.conf;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,5 +4,5 @@ server {
|
|||
<% if ipv6_enable == 'true' && (defined? ipaddress6) %>
|
||||
listen [<%= ipv6_listen_ip %>]:<%= ipv6_listen_port %> default ipv6only=on;
|
||||
<% end %>
|
||||
server_name <%= rewrite_www_to_non_www ? name.gsub(/^www\./, '') : name %>;
|
||||
server_name <%= rewrite_www_to_non_www ? name.gsub(/^www\./, '') : server_name.join(" ") %>;
|
||||
access_log <%= scope.lookupvar('nginx::params::nx_logdir')%>/<%= name %>.access.log;
|
||||
|
|
3
templates/vhost/vhost_location_alias.erb
Normal file
3
templates/vhost/vhost_location_alias.erb
Normal file
|
@ -0,0 +1,3 @@
|
|||
location <%= location %> {
|
||||
alias <%= location_alias %>;
|
||||
}
|
8
tests/location_alias.pp
Normal file
8
tests/location_alias.pp
Normal file
|
@ -0,0 +1,8 @@
|
|||
include nginx
|
||||
|
||||
nginx::resource::location { 'www.test.com-alias':
|
||||
ensure => present,
|
||||
location => '/some/url',
|
||||
location_alias => '/new/url/',
|
||||
vhost => 'www.test.com',
|
||||
}
|
Loading…
Reference in a new issue