diff --git a/README.md b/README.md index 186f46ddf..e037bb137 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ class { 'nginx': } ### A simple reverse proxy ```puppet -nginx::resource::vhost { 'kibana.myhost.com': +nginx::resource::server { 'kibana.myhost.com': listen_port => 80, proxy => 'http://localhost:5601', } @@ -45,7 +45,7 @@ nginx::resource::vhost { 'kibana.myhost.com': ### A virtual host with static content ```puppet -nginx::resource::vhost { 'www.puppetlabs.com': +nginx::resource::server { 'www.puppetlabs.com': www_root => '/var/www/www.puppetlabs.com', } ``` @@ -61,7 +61,7 @@ nginx::resource::upstream { 'puppet_rack_app': ], } -nginx::resource::vhost { 'rack.puppetlabs.com': +nginx::resource::server { 'rack.puppetlabs.com': proxy => 'http://puppet_rack_app', } ``` @@ -88,26 +88,26 @@ nginx::resource::mailhost { 'domain1.example': ## SSL configuration -By default, creating a vhost resource will only create a HTTP vhost. To also create a HTTPS (SSL-enabled) vhost, set `ssl => true` on the vhost. You will have a HTTP server listening on `listen_port` (port `80` by default) and a HTTPS server listening on `ssl_port` (port `443` by default). Both vhosts will have the same `server_name` and a similar configuration. +By default, creating a server resource will only create a HTTP server. To also create a HTTPS (SSL-enabled) server, set `ssl => true` on the server. You will have a HTTP server listening on `listen_port` (port `80` by default) and a HTTPS server listening on `ssl_port` (port `443` by default). Both servers will have the same `server_name` and a similar configuration. -To create only a HTTPS vhost, set `ssl => true` and also set `listen_port` to the same value as `ssl_port`. Setting these to the same value disables the HTTP vhost. The resulting vhost will be listening on `ssl_port`. +To create only a HTTPS server, set `ssl => true` and also set `listen_port` to the same value as `ssl_port`. Setting these to the same value disables the HTTP server. The resulting server will be listening on `ssl_port`. ### Locations -Locations require specific settings depending on whether they should be included in the HTTP, HTTPS or both vhosts. +Locations require specific settings depending on whether they should be included in the HTTP, HTTPS or both servers. -#### HTTP only vhost (default) -If you only have a HTTP vhost (i.e. `ssl => false` on the vhost) make sure you don't set `ssl => true` on any location you associate with the vhost. +#### HTTP only server (default) +If you only have a HTTP server (i.e. `ssl => false` on the server) make sure you don't set `ssl => true` on any location you associate with the server. -#### HTTP and HTTPS vhost -If you set `ssl => true` and also set `listen_port` and `ssl_port` to different values on the vhost you will need to be specific with the location settings since you will have a HTTP vhost listening on `listen_port` and a HTTPS vhost listening on `ssl_port`: +#### HTTP and HTTPS server +If you set `ssl => true` and also set `listen_port` and `ssl_port` to different values on the server you will need to be specific with the location settings since you will have a HTTP server listening on `listen_port` and a HTTPS server listening on `ssl_port`: * To add a location to only the HTTP server, set `ssl => false` on the location (this is the default). * To add a location to both the HTTP and HTTPS server, set `ssl => true` on the location, and ensure `ssl_only => false` (which is the default value for `ssl_only`). * To add a location only to the HTTPS server, set both `ssl => true` and `ssl_only => true` on the location. -#### HTTPS only vhost -If you have set `ssl => true` and also set `listen_port` and `ssl_port` to the same value on the vhost, you will have a single HTTPS vhost listening on `ssl_port`. To add a location to this vhost set `ssl => true` and `ssl_only => true` on the location. +#### HTTPS only server +If you have set `ssl => true` and also set `listen_port` and `ssl_port` to the same value on the server, you will have a single HTTPS server listening on `ssl_port`. To add a location to this server set `ssl => true` and `ssl_only => true` on the location. ## Hiera Support @@ -121,7 +121,7 @@ nginx::nginx_upstreams: - localhost:3000 - localhost:3001 - localhost:3002 -nginx::nginx_vhosts: +nginx::nginx_servers: 'www.puppetlabs.com': www_root: '/var/www/www.puppetlabs.com' 'rack.puppetlabs.com': @@ -129,11 +129,11 @@ nginx::nginx_vhosts: nginx::nginx_locations: 'static': location: '~ "^/static/[0-9a-fA-F]{8}\/(.*)$"' - vhost: www.puppetlabs.com + server: www.puppetlabs.com www_root: /var/www/html 'userContent': location: /userContent - vhost: www.puppetlabs.com + server: www.puppetlabs.com www_root: /var/www/html nginx::nginx_mailhosts: 'smtp': @@ -174,9 +174,9 @@ Package source `passenger` will add [Phusion Passenger repository](https://oss-b For each virtual host you should specify which ruby should be used. ```puppet -nginx::resource::vhost { 'www.puppetlabs.com': +nginx::resource::server { 'www.puppetlabs.com': www_root => '/var/www/www.puppetlabs.com', - vhost_cfg_append => { + server_cfg_append => { 'passenger_enabled' => 'on', 'passenger_ruby' => '/usr/bin/ruby', } @@ -188,7 +188,7 @@ nginx::resource::vhost { 'www.puppetlabs.com': Virtual host config for serving puppet master: ```puppet -nginx::resource::vhost { 'puppet': +nginx::resource::server { 'puppet': ensure => present, server_name => ['puppet'], listen_port => 8140, @@ -196,7 +196,7 @@ nginx::resource::vhost { 'puppet': ssl_cert => '/var/lib/puppet/ssl/certs/example.com.pem', ssl_key => '/var/lib/puppet/ssl/private_keys/example.com.pem', ssl_port => 8140, - vhost_cfg_append => { + server_cfg_append => { 'passenger_enabled' => 'on', 'passenger_ruby' => '/usr/bin/ruby', 'ssl_crl' => '/var/lib/puppet/ssl/ca/ca_crl.pem', @@ -215,7 +215,7 @@ nginx::resource::vhost { 'puppet': } ``` -### Example puppet class calling nginx::vhost with HTTPS FastCGI and redirection of HTTP +### Example puppet class calling nginx::server with HTTPS FastCGI and redirection of HTTP ```puppet @@ -228,7 +228,7 @@ define web::nginx_ssl_with_redirect ( $www_root = "${full_web_path}/${name}/", $location_cfg_append = undef, ) { - nginx::resource::vhost { "${name}.${::domain}": + nginx::resource::server { "${name}.${::domain}": ensure => present, www_root => "${full_web_path}/${name}/", location_cfg_append => { 'rewrite' => '^ https://$server_name$request_uri? permanent' }, @@ -240,7 +240,7 @@ define web::nginx_ssl_with_redirect ( $tmp_www_root = $www_root } - nginx::resource::vhost { "${name}.${::domain} ${name}": + nginx::resource::server { "${name}.${::domain} ${name}": ensure => present, listen_port => 443, www_root => $tmp_www_root, @@ -258,7 +258,7 @@ define web::nginx_ssl_with_redirect ( ensure => present, ssl => true, ssl_only => true, - vhost => "${name}.${::domain} ${name}", + server => "${name}.${::domain} ${name}", www_root => "${full_web_path}/${name}/", location => '~ \.php$', index_files => ['index.php', 'index.html', 'index.htm'], diff --git a/docs/hiera.md b/docs/hiera.md index f6b5d8525..ad46abfc3 100644 --- a/docs/hiera.md +++ b/docs/hiera.md @@ -33,7 +33,7 @@ Assume you have the following code block: class { 'nginx' : manage_repo => false, confd_purge => true, - vhost_purge => true, + server_purge => true, } ``` @@ -44,7 +44,7 @@ Anchor['nginx::begin'] -> class { 'nginx::config' : confd_purge => true, - vhost_purge => true, + server_purge => true, } class { 'nginx' : diff --git a/docs/quickstart.md b/docs/quickstart.md index 32b6b8897..ae09fb482 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -22,7 +22,7 @@ The choices here are `nginx-stable` (the current 'production' level release), `n Calling the `nginx` class from your manifest simply installs the NGINX software and puts some basic configuration in place. In this state, NGINX will not serve web pages or proxy to other services - for that, we need to define a *server*. In NGINX terminology, a *server* is how we define our services (such as websites) with a name. (If you are used to configuring Apache, a server is identical to an Apache *virtual host*.) A simple virtual host that serves static web pages can be defined with a server name and a *web root*, or the directory where our HTML pages are located. ``` - nginx::resource::vhost{'www.myhost.com': + nginx::resource::server{'www.myhost.com': www_root => '/opt/html/', } ``` @@ -35,7 +35,7 @@ Setting up a simple static webserver is straightforward, but is usually not the ``` nginx::resource::location{'/blog': proxy => 'http://192.168.99.1/' , - vhost => 'www.myhost.com' + server => 'www.myhost.com' } ``` This will proxy any requests made to `http://www.myhost.com/blog` to the URL `http://192.168.99.1/`. Pay special attention to the use of `/` at the end of the URL we are proxying to - that will allow your query parameters or subfolder structure on your secondary webserver to remain intact. @@ -56,7 +56,7 @@ We can expand on these simple proxies by defining *upstream* resources for our w ``` nginx::resource::location{'/blog': proxy => 'http://upstream_app/' , - vhost => 'www.myhost.com' + server => 'www.myhost.com' } ``` Now `/blog` will proxy requests to services defined in our `upstream_app` resource. @@ -78,13 +78,13 @@ Combining our configurations above into a single manifest, our code block looks ], } - nginx::resource::vhost{'www.myhost.com': + nginx::resource::server{'www.myhost.com': www_root => '/opt/html/', } nginx::resource::location{'/proxy': proxy => 'http://upstream_app/' , - vhost => 'www.myhost.com', + server => 'www.myhost.com', } ``` diff --git a/examples/location_alias.pp b/examples/location_alias.pp index 689768b5f..ec405ef50 100644 --- a/examples/location_alias.pp +++ b/examples/location_alias.pp @@ -4,5 +4,5 @@ ensure => present, location => '/some/url', location_alias => '/new/url/', - vhost => 'www.test.com', + server => 'www.test.com', } diff --git a/examples/location_params.pp b/examples/location_params.pp index 40f532e88..978518772 100644 --- a/examples/location_params.pp +++ b/examples/location_params.pp @@ -3,7 +3,7 @@ ::nginx::resource::location { 'www.test.com-params': ensure => present, location => '/some/url', - vhost => 'www.test.com', + server => 'www.test.com', fastcgi_param => { 'APP_ENV' => 'production', 'APP_VERSION' => '0.1.10', diff --git a/examples/vhost.pp b/examples/vhost.pp index f50634b6e..59c996e1d 100644 --- a/examples/vhost.pp +++ b/examples/vhost.pp @@ -1,12 +1,12 @@ include ::nginx -::nginx::resource::vhost { 'test.local test': +::nginx::resource::server { 'test.local test': ensure => present, ipv6_enable => true, proxy => 'http://proxypass', } -::nginx::resource::vhost { 'test.local:8080': +::nginx::resource::server { 'test.local:8080': ensure => present, listen_port => 8080, server_name => ['test.local test'], diff --git a/examples/vhost_ssl.pp b/examples/vhost_ssl.pp index cef2c9e96..23a569bd0 100644 --- a/examples/vhost_ssl.pp +++ b/examples/vhost_ssl.pp @@ -1,6 +1,6 @@ include ::nginx -::nginx::resource::vhost { 'test3.local test3': +::nginx::resource::server { 'test3.local test3': ensure => present, www_root => '/var/www/nginx-default', ssl => true, @@ -9,7 +9,7 @@ ssl_key => 'puppet:///modules/sslkey/whildcard_mydomain.key', } -::nginx::resource::vhost { 'test2.local test2': +::nginx::resource::server { 'test2.local test2': ensure => present, www_root => '/var/www/nginx-default', ssl => true, @@ -21,12 +21,12 @@ ensure => present, www_root => '/var/www/bob', location => '/bob', - vhost => 'test2.local test2', + server => 'test2.local test2', } ::nginx::resource::location { 'test3.local-bob': ensure => present, www_root => '/var/www/bob', location => '/bob', - vhost => 'test3.local test3', + server => 'test3.local test3', } diff --git a/manifests/config.pp b/manifests/config.pp index 0907a4c27..8c2de3d83 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -37,7 +37,7 @@ $sites_available_mode = $::nginx::params::sites_available_mode, $super_user = $::nginx::params::super_user, $temp_dir = $::nginx::params::temp_dir, - $vhost_purge = false, + $server_purge = false, # Primary Templates $conf_template = 'nginx/conf.d/nginx.conf.erb', @@ -143,7 +143,7 @@ } validate_bool($confd_only) validate_bool($confd_purge) - validate_bool($vhost_purge) + validate_bool($server_purge) if ( $proxy_cache_path != false) { if ( is_string($proxy_cache_path) or is_hash($proxy_cache_path)) {} else { @@ -235,10 +235,10 @@ ensure => directory, } if $confd_purge { - # Err on the side of caution - make sure *both* $vhost_purge and + # Err on the side of caution - make sure *both* $server_purge and # $confd_purge are set if $confd_only is set, before purging files # ${conf_dir}/conf.d - if (($confd_only and $vhost_purge) or !$confd_only) { + if (($confd_only and $server_purge) or !$confd_only) { File["${conf_dir}/conf.d"] { purge => true, recurse => true, @@ -290,7 +290,7 @@ file { "${conf_dir}/sites-enabled": ensure => directory, } - if $vhost_purge { + if $server_purge { File["${conf_dir}/sites-available"] { purge => true, recurse => true, @@ -309,7 +309,7 @@ file { "${conf_dir}/streams-available": ensure => directory, } - if $vhost_purge == true { + if $server_purge == true { File["${conf_dir}/streams-enabled"] { purge => true, recurse => true, diff --git a/manifests/init.pp b/manifests/init.pp index 8bb5caacb..1a52460d3 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -97,7 +97,7 @@ $sites_available_mode = undef, $super_user = undef, $temp_dir = undef, - $vhost_purge = undef, + $server_purge = undef, # Primary Templates $conf_template = undef, @@ -127,8 +127,8 @@ $nginx_mailhosts = {}, $nginx_streamhosts = {}, $nginx_upstreams = {}, - $nginx_vhosts = {}, - $nginx_vhosts_defaults = {}, + $nginx_servers = {}, + $nginx_servers_defaults = {}, ### END Hiera Lookups ### ) inherits ::nginx::params { @@ -204,7 +204,7 @@ $temp_dir or $types_hash_bucket_size or $types_hash_max_size or - $vhost_purge or + $server_purge or $worker_connections or $worker_processes or $worker_rlimit_nofile or @@ -291,7 +291,7 @@ temp_dir => $temp_dir, types_hash_bucket_size => $types_hash_bucket_size, types_hash_max_size => $types_hash_max_size, - vhost_purge => $vhost_purge, + server_purge => $server_purge, worker_connections => $worker_connections, worker_processes => $worker_processes, worker_rlimit_nofile => $worker_rlimit_nofile, @@ -309,7 +309,7 @@ Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service'] create_resources('nginx::resource::upstream', $nginx_upstreams) - create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults) + create_resources('nginx::resource::server', $nginx_servers, $nginx_servers_defaults) create_resources('nginx::resource::location', $nginx_locations) create_resources('nginx::resource::mailhost', $nginx_mailhosts) create_resources('nginx::resource::streamhost', $nginx_streamhosts) diff --git a/manifests/resource/location.pp b/manifests/resource/location.pp index 34b005e8b..7ab19f66a 100644 --- a/manifests/resource/location.pp +++ b/manifests/resource/location.pp @@ -7,7 +7,7 @@ # (present|absent) # [*internal*] - Indicates whether or not this loation can be # used for internal requests only. Default: false -# [*vhost*] - Defines the default vHost for this location +# [*server*] - Defines the default vHost for this location # entry to include with # [*location*] - Specifies the URI associated with this location # entry @@ -30,9 +30,9 @@ # value of 90 seconds # [*proxy_connect_timeout*] - Override the default the proxy connect timeout # value of 90 seconds -# [*proxy_set_header*] - Array of vhost headers to set -# [*proxy_hide_header*] - Array of vhost headers to hide -# [*proxy_pass_header*] - Array of vhost headers to pass +# [*proxy_set_header*] - Array of server headers to set +# [*proxy_hide_header*] - Array of server headers to hide +# [*proxy_pass_header*] - Array of server headers to pass # [*fastcgi*] - location of fastcgi (host:port) # [*fastcgi_param*] - Set additional custom fastcgi_params # [*fastcgi_params*] - optional alternative fastcgi_params file to use @@ -110,7 +110,7 @@ # ensure => present, # www_root => '/var/www/bob', # location => '/bob', -# vhost => 'test2.local', +# server => 'test2.local', # } # # Custom config example to limit location on localhost, @@ -124,7 +124,7 @@ # ensure => present, # www_root => '/var/www/bob', # location => '/bob', -# vhost => 'test2.local', +# server => 'test2.local', # location_cfg_append => $my_config, # } # @@ -133,7 +133,7 @@ # ensure => present, # www_root => '/var/www/bob', # location => '/bob', -# vhost => 'test2.local', +# server => 'test2.local', # fastcgi_param => { # 'APP_ENV' => 'local', # } @@ -144,7 +144,7 @@ # ensure => present, # www_root => '/var/www/bob', # location => '/bob', -# vhost => 'test2.local', +# server => 'test2.local', # uwsgi_param => { # 'APP_ENV' => 'local', # } @@ -154,7 +154,7 @@ $ensure = present, $internal = false, $location = $name, - $vhost = undef, + $server = undef, $www_root = undef, $autoindex = undef, $index_files = [ @@ -223,8 +223,8 @@ validate_re($ensure, '^(present|absent)$', "${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.") validate_string($location) - if ($vhost != undef) { - validate_string($vhost) + if ($server != undef) { + validate_string($server) } if ($www_root != undef) { validate_string($www_root) @@ -370,14 +370,14 @@ } ## Check for various error conditions - if ($vhost == undef) { + if ($server == undef) { fail('Cannot create a location reference without attaching to a virtual host') } if !($www_root or $proxy or $location_alias or $stub_status or $fastcgi or $uwsgi or $location_custom_cfg or $internal or $try_files or $location_allow or $location_deny) { - fail("Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in ${vhost}:${title}") + fail("Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in ${server}:${title}") } if ($www_root and $proxy) { - fail("Cannot define both directory and proxy in ${vhost}:${title}") + fail("Cannot define both directory and proxy in ${server}:${title}") } # Use proxy, fastcgi or uwsgi template if $proxy is defined, otherwise use directory template. @@ -386,42 +386,42 @@ warning('The $fastcgi_script parameter is deprecated; please use $fastcgi_param instead to define custom fastcgi_params!') } - $vhost_sanitized = regsubst($vhost, ' ', '_', 'G') + $server_sanitized = regsubst($server, ' ', '_', 'G') if $::nginx::config::confd_only { - $vhost_dir = "${::nginx::config::conf_dir}/conf.d" + $server_dir = "${::nginx::config::conf_dir}/conf.d" } else { - $vhost_dir = "${::nginx::config::conf_dir}/sites-available" + $server_dir = "${::nginx::config::conf_dir}/sites-available" } - $config_file = "${vhost_dir}/${vhost_sanitized}.conf" + $config_file = "${server_dir}/${server_sanitized}.conf" $location_sanitized_tmp = regsubst($location, '\/', '_', 'G') $location_sanitized = regsubst($location_sanitized_tmp, '\\\\', '_', 'G') # Use proxy or fastcgi template if $proxy is defined, otherwise use directory template. if ($proxy != undef) { - $content_real = template('nginx/vhost/locations/proxy.erb') + $content_real = template('nginx/server/locations/proxy.erb') } elsif ($location_alias != undef) { - $content_real = template('nginx/vhost/locations/alias.erb') + $content_real = template('nginx/server/locations/alias.erb') } elsif ($stub_status != undef) { - $content_real = template('nginx/vhost/locations/stub_status.erb') + $content_real = template('nginx/server/locations/stub_status.erb') } elsif ($fastcgi != undef) { - $content_real = template('nginx/vhost/locations/fastcgi.erb') + $content_real = template('nginx/server/locations/fastcgi.erb') } elsif ($uwsgi != undef) { - $content_real = template('nginx/vhost/locations/uwsgi.erb') + $content_real = template('nginx/server/locations/uwsgi.erb') } elsif ($www_root != undef) { - $content_real = template('nginx/vhost/locations/directory.erb') + $content_real = template('nginx/server/locations/directory.erb') } elsif ($try_files != undef) { - $content_real = template('nginx/vhost/locations/try_files.erb') + $content_real = template('nginx/server/locations/try_files.erb') } else { - $content_real = template('nginx/vhost/locations/empty.erb') + $content_real = template('nginx/server/locations/empty.erb') } if $ensure == present and $fastcgi != undef and !defined(File[$fastcgi_params]) { file { $fastcgi_params: ensure => present, mode => '0770', - content => template('nginx/vhost/fastcgi_params.erb'), + content => template('nginx/server/fastcgi_params.erb'), } } @@ -429,7 +429,7 @@ file { $uwsgi_params: ensure => present, mode => '0770', - content => template('nginx/vhost/uwsgi_params.erb'), + content => template('nginx/server/uwsgi_params.erb'), } } @@ -437,12 +437,12 @@ ## Create stubs for vHost File Fragment Pattern $location_md5 = md5($location) if ($ssl_only != true) { - concat::fragment { "${vhost_sanitized}-${priority}-${location_md5}": + concat::fragment { "${server_sanitized}-${priority}-${location_md5}": target => $config_file, content => join([ - template('nginx/vhost/location_header.erb'), + template('nginx/server/location_header.erb'), $content_real, - template('nginx/vhost/location_footer.erb'), + template('nginx/server/location_footer.erb'), ], ''), order => $priority, } @@ -452,12 +452,12 @@ if ($ssl == true or $ssl_only == true) { $ssl_priority = $priority + 300 - concat::fragment { "${vhost_sanitized}-${ssl_priority}-${location_md5}-ssl": + concat::fragment { "${server_sanitized}-${ssl_priority}-${location_md5}-ssl": target => $config_file, content => join([ - template('nginx/vhost/location_header.erb'), + template('nginx/server/location_header.erb'), $content_real, - template('nginx/vhost/location_footer.erb'), + template('nginx/server/location_footer.erb'), ], ''), order => $ssl_priority, } diff --git a/manifests/resource/vhost.pp b/manifests/resource/vhost.pp index 3791e5c7a..0c8e24269 100644 --- a/manifests/resource/vhost.pp +++ b/manifests/resource/vhost.pp @@ -1,9 +1,9 @@ -# define: nginx::resource::vhost +# define: nginx::resource::server # # This definition creates a virtual host # # Parameters: -# [*ensure*] - Enables or disables the specified vhost +# [*ensure*] - Enables or disables the specified server # (present|absent) # [*listen_ip*] - Default IP Address for NGINX to listen with this # vHost on. Defaults to all interfaces (*) @@ -50,7 +50,7 @@ # [*fastcgi_script*] - optional SCRIPT_FILE parameter # [*uwsgi_read_timeout*] - optional value for uwsgi_read_timeout # [*ssl*] - Indicates whether to setup SSL bindings for this -# vhost. +# server. # [*ssl_cert*] - Pre-generated SSL Certificate file to reference # for SSL Support. This is not generated by this module. # [*ssl_client_cert*] - Pre-generated SSL Certificate file to reference @@ -90,7 +90,7 @@ # OCSP responses if ssl_stapling is enabled. # [*spdy*] - Toggles SPDY protocol. # [*http2*] - Toggles HTTP/2 protocol. -# [*server_name*] - List of vhostnames for which this vhost will +# [*server_name*] - List of servernames for which this server will # respond. Default [$name]. # [*www_root*] - Specifies the location on disk for files to be # read from. Cannot be set in conjunction with $proxy @@ -132,26 +132,26 @@ # [*location_raw_append*] - A single string, or an array of strings # to append to the location directive (after custom_cfg directives). NOTE: # YOU are responsible for a semicolon on each line that requires one. -# [*vhost_cfg_append*] - It expects a hash with custom directives to -# put after everything else inside vhost -# [*vhost_cfg_prepend*] - It expects a hash with custom directives to -# put before everything else inside vhost -# [*vhost_cfg_ssl_append*] - It expects a hash with custom directives to -# put after everything else inside vhost ssl -# [*vhost_cfg_ssl_prepend*] - It expects a hash with custom directives to -# put before everything else inside vhost ssl +# [*server_cfg_append*] - It expects a hash with custom directives to +# put after everything else inside server +# [*server_cfg_prepend*] - It expects a hash with custom directives to +# put before everything else inside server +# [*server_cfg_ssl_append*] - It expects a hash with custom directives to +# put after everything else inside server ssl +# [*server_cfg_ssl_prepend*] - It expects a hash with custom directives to +# put before everything else inside server ssl # [*rewrite_to_https*] - Adds a server directive and rewrite rule to # rewrite to ssl -# [*include_files*] - Adds include files to vhost +# [*include_files*] - Adds include files to server # [*access_log*] - Where to write access log (log format can be # set with $format_log). This can be either a string or an array; in the # latter case, multiple lines will be created. Additionally, unlike the -# earlier behavior, setting it to 'absent' in the vhost context will remove -# this directive entirely from the vhost stanza, rather than setting a -# default. Can also be disabled for this vhost with the string 'off'. +# earlier behavior, setting it to 'absent' in the server context will remove +# this directive entirely from the server stanza, rather than setting a +# default. Can also be disabled for this server with the string 'off'. # [*error_log*] - Where to write error log. May add additional # options like error level to the end. May set to 'absent', in which case -# it will be omitted in this vhost stanza (and default to nginx.conf setting) +# it will be omitted in this server stanza (and default to nginx.conf setting) # [*passenger_cgi_param*] - Allows one to define additional CGI environment # variables to pass to the backend application # [*passenger_set_header*] - Allows one to set headers to pass to the @@ -171,25 +171,25 @@ # [*owner*] - Defines owner of the .conf file # [*group*] - Defines group of the .conf file # [*mode*] - Defines mode of the .conf file -# [*maintenance*] - A boolean value to set a vhost in maintenance +# [*maintenance*] - A boolean value to set a server in maintenance # [*maintenance_value*] - Value to return when maintenance is on. # Default to return 503 # [*error_pages*] - Hash: setup errors pages, hash key is the http # code and hash value the page -# [*locations*] - Hash of vhosts ressources used by this vhost +# [*locations*] - Hash of servers ressources used by this server # Actions: # # Requires: # # Sample Usage: -# nginx::resource::vhost { 'test2.local': +# nginx::resource::server { 'test2.local': # ensure => present, # www_root => '/var/www/nginx-default', # ssl => true, # ssl_cert => '/tmp/server.crt', # ssl_key => '/tmp/server.pem', # } -define nginx::resource::vhost ( +define nginx::resource::server ( $ensure = 'present', $listen_ip = '*', $listen_port = 80, @@ -274,10 +274,10 @@ $raw_append = undef, $location_raw_prepend = undef, $location_raw_append = undef, - $vhost_cfg_prepend = undef, - $vhost_cfg_append = undef, - $vhost_cfg_ssl_prepend = undef, - $vhost_cfg_ssl_append = undef, + $server_cfg_prepend = undef, + $server_cfg_append = undef, + $server_cfg_ssl_prepend = undef, + $server_cfg_ssl_append = undef, $include_files = undef, $access_log = undef, $error_log = undef, @@ -506,17 +506,17 @@ if ($auth_basic_user_file != undef) { validate_string($auth_basic_user_file) } - if ($vhost_cfg_prepend != undef) { - validate_hash($vhost_cfg_prepend) + if ($server_cfg_prepend != undef) { + validate_hash($server_cfg_prepend) } - if ($vhost_cfg_append != undef) { - validate_hash($vhost_cfg_append) + if ($server_cfg_append != undef) { + validate_hash($server_cfg_append) } - if ($vhost_cfg_ssl_prepend != undef) { - validate_hash($vhost_cfg_ssl_prepend) + if ($server_cfg_ssl_prepend != undef) { + validate_hash($server_cfg_ssl_prepend) } - if ($vhost_cfg_ssl_append != undef) { - validate_hash($vhost_cfg_ssl_append) + if ($server_cfg_ssl_append != undef) { + validate_hash($server_cfg_ssl_append) } if ($include_files != undef) { validate_array($include_files) @@ -561,18 +561,18 @@ # Variables if $::nginx::config::confd_only { - $vhost_dir = "${::nginx::config::conf_dir}/conf.d" + $server_dir = "${::nginx::config::conf_dir}/conf.d" } else { - $vhost_dir = "${::nginx::config::conf_dir}/sites-available" - $vhost_enable_dir = "${::nginx::config::conf_dir}/sites-enabled" - $vhost_symlink_ensure = $ensure ? { + $server_dir = "${::nginx::config::conf_dir}/sites-available" + $server_enable_dir = "${::nginx::config::conf_dir}/sites-enabled" + $server_symlink_ensure = $ensure ? { 'absent' => absent, default => 'link', } } $name_sanitized = regsubst($name, ' ', '_', 'G') - $config_file = "${vhost_dir}/${name_sanitized}.conf" + $config_file = "${server_dir}/${name_sanitized}.conf" File { ensure => $ensure ? { @@ -603,7 +603,7 @@ group => $group, mode => $mode, notify => Class['::nginx::service'], - require => File[$vhost_dir], + require => File[$server_dir], } $ssl_only = ($ssl == true) and (($ssl_port + 0) == ($listen_port + 0)) @@ -612,7 +612,7 @@ # Create the default location reference for the vHost nginx::resource::location {"${name_sanitized}-default": ensure => $ensure, - vhost => $name_sanitized, + server => $name_sanitized, ssl => $ssl, ssl_only => $ssl_only, location => '/', @@ -663,7 +663,7 @@ file { $fastcgi_params: ensure => present, mode => '0770', - content => template('nginx/vhost/fastcgi_params.erb'), + content => template('nginx/server/fastcgi_params.erb'), } } @@ -671,14 +671,14 @@ file { $uwsgi_params: ensure => present, mode => '0660', - content => template('nginx/vhost/uwsgi_params.erb'), + content => template('nginx/server/uwsgi_params.erb'), } } if (($listen_port + 0) != ($ssl_port + 0)) { concat::fragment { "${name_sanitized}-header": target => $config_file, - content => template('nginx/vhost/vhost_header.erb'), + content => template('nginx/server/server_header.erb'), order => '001', } } @@ -687,7 +687,7 @@ if (($listen_port + 0) != ($ssl_port + 0)) { concat::fragment { "${name_sanitized}-footer": target => $config_file, - content => template('nginx/vhost/vhost_footer.erb'), + content => template('nginx/server/server_footer.erb'), order => '699', } } @@ -698,22 +698,22 @@ concat::fragment { "${name_sanitized}-ssl-header": target => $config_file, - content => template('nginx/vhost/vhost_ssl_header.erb'), + content => template('nginx/server/server_ssl_header.erb'), order => '700', } concat::fragment { "${name_sanitized}-ssl-footer": target => $config_file, - content => template('nginx/vhost/vhost_ssl_footer.erb'), + content => template('nginx/server/server_ssl_footer.erb'), order => '999', } } unless $::nginx::config::confd_only { file{ "${name_sanitized}.conf symlink": - ensure => $vhost_symlink_ensure, - path => "${vhost_enable_dir}/${name_sanitized}.conf", + ensure => $server_symlink_ensure, + path => "${server_enable_dir}/${name_sanitized}.conf", target => $config_file, - require => [File[$vhost_dir], File[$vhost_enable_dir], Concat[$config_file]], + require => [File[$server_dir], File[$server_enable_dir], Concat[$config_file]], notify => Class['::nginx::service'], } } @@ -722,7 +722,7 @@ create_resources('::nginx::resource::geo', $geo_mappings) create_resources('::nginx::resource::location', $locations, { ensure => $ensure, - vhost => $name_sanitized, + server => $name_sanitized, ssl => $ssl, ssl_only => $ssl_only, www_root => $www_root, diff --git a/manifests/service.pp b/manifests/service.pp index 4d062580b..1a69bd74b 100644 --- a/manifests/service.pp +++ b/manifests/service.pp @@ -1,6 +1,6 @@ # Class: nginx::service # -# This module manages NGINX service management and vhost rebuild +# This module manages NGINX service management and server rebuild # # Parameters: # diff --git a/spec/acceptance/nginx_proxy_spec.rb b/spec/acceptance/nginx_proxy_spec.rb index f69e56b2b..839f854bc 100644 --- a/spec/acceptance/nginx_proxy_spec.rb +++ b/spec/acceptance/nginx_proxy_spec.rb @@ -12,7 +12,7 @@ class { 'nginx': } 'localhost:3002', ], } - nginx::resource::vhost { 'rack.puppetlabs.com': + nginx::resource::server { 'rack.puppetlabs.com': ensure => present, proxy => 'http://puppet_rack_app', } diff --git a/spec/acceptance/nginx_vhost_spec.rb b/spec/acceptance/nginx_vhost_spec.rb index 62798e2a4..c660b71e2 100644 --- a/spec/acceptance/nginx_vhost_spec.rb +++ b/spec/acceptance/nginx_vhost_spec.rb @@ -1,11 +1,11 @@ require 'spec_helper_acceptance' -describe 'nginx::resource::vhost define:' do - context 'new vhost on port 80' do - it 'configures a nginx vhost' do +describe 'nginx::resource::server define:' do + context 'new server on port 80' do + it 'configures a nginx server' do pp = " class { 'nginx': } - nginx::resource::vhost { 'www.puppetlabs.com': + nginx::resource::server { 'www.puppetlabs.com': ensure => present, www_root => '/var/www/www.puppetlabs.com', } @@ -48,10 +48,10 @@ class { 'nginx': } end context 'should run successfully with ssl' do - it 'configures a nginx SSL vhost' do + it 'configures a nginx SSL server' do pp = " class { 'nginx': } - nginx::resource::vhost { 'www.puppetlabs.com': + nginx::resource::server { 'www.puppetlabs.com': ensure => present, ssl => true, ssl_cert => '/etc/pki/tls/certs/blah.cert', diff --git a/spec/classes/config_spec.rb b/spec/classes/config_spec.rb index a9af8a969..ac962cba5 100644 --- a/spec/classes/config_spec.rb +++ b/spec/classes/config_spec.rb @@ -668,8 +668,8 @@ end end - context 'when vhost_purge true' do - let(:params) { { vhost_purge: true } } + context 'when server_purge true' do + let(:params) { { server_purge: true } } it do is_expected.to contain_file('/etc/nginx/sites-available').with( purge: true, @@ -684,12 +684,12 @@ end end - context 'when confd_purge true, vhost_purge true, and confd_only true' do + context 'when confd_purge true, server_purge true, and confd_only true' do let(:params) do { confd_purge: true, confd_only: true, - vhost_purge: true + server_purge: true } end it do @@ -706,7 +706,7 @@ end end - context 'when confd_purge true, vhost_purge default (false), confd_only true' do + context 'when confd_purge true, server_purge default (false), confd_only true' do let(:params) do { confd_purge: true, @@ -729,8 +729,8 @@ end end - context 'when vhost_purge false' do - let(:params) { { vhost_purge: false } } + context 'when server_purge false' do + let(:params) { { server_purge: false } } it do is_expected.to contain_file('/etc/nginx/sites-available').without( %w( diff --git a/spec/classes/nginx_spec.rb b/spec/classes/nginx_spec.rb index 5339f22f5..eb1f3d90a 100644 --- a/spec/classes/nginx_spec.rb +++ b/spec/classes/nginx_spec.rb @@ -10,9 +10,9 @@ let :params do { nginx_upstreams: { 'upstream1' => { 'members' => ['localhost:3000'] } }, - nginx_vhosts: { 'test2.local' => { 'www_root' => '/' } }, - nginx_vhosts_defaults: { 'listen_options' => 'default_server' }, - nginx_locations: { 'test2.local' => { 'vhost' => 'test2.local', 'www_root' => '/' } }, + nginx_servers: { 'test2.local' => { 'www_root' => '/' } }, + nginx_servers_defaults: { 'listen_options' => 'default_server' }, + nginx_locations: { 'test2.local' => { 'server' => 'test2.local', 'www_root' => '/' } }, nginx_mailhosts: { 'smtp.test2.local' => { 'auth_http' => 'server2.example/cgi-bin/auth', 'protocol' => 'smtp', 'listen_port' => 587 } }, nginx_streamhosts: { 'streamhost1' => { 'proxy' => 'streamproxy' } } } @@ -29,8 +29,8 @@ it { is_expected.to contain_class('nginx::service').that_subscribes_to('Class[nginx::config]') } it { is_expected.to contain_anchor('nginx::end').that_requires('Class[nginx::service]') } it { is_expected.to contain_nginx__resource__upstream('upstream1') } - it { is_expected.to contain_nginx__resource__vhost('test2.local') } - it { is_expected.to contain_nginx__resource__vhost('test2.local').with_listen_options('default_server') } + it { is_expected.to contain_nginx__resource__server('test2.local') } + it { is_expected.to contain_nginx__resource__server('test2.local').with_listen_options('default_server') } it { is_expected.to contain_nginx__resource__location('test2.local') } it { is_expected.to contain_nginx__resource__mailhost('smtp.test2.local') } it { is_expected.to contain_nginx__resource__streamhost('streamhost1').with_proxy('streamproxy') } diff --git a/spec/defines/resource_location_spec.rb b/spec/defines/resource_location_spec.rb index 45991af8e..021ea63e7 100644 --- a/spec/defines/resource_location_spec.rb +++ b/spec/defines/resource_location_spec.rb @@ -16,18 +16,18 @@ let :params do { www_root: '/var/www/rspec', - vhost: 'vhost1' + server: 'server1' } end it { is_expected.to contain_class('nginx::config') } - it { is_expected.to contain_concat__fragment('vhost1-500-33c6aa94600c830ad2d316bb4db36724').with_content(%r{location rspec-test}) } + it { is_expected.to contain_concat__fragment('server1-500-33c6aa94600c830ad2d316bb4db36724').with_content(%r{location rspec-test}) } it { is_expected.not_to contain_file('/etc/nginx/fastcgi_params') } - it { is_expected.not_to contain_concat__fragment('vhost1-800-rspec-test-ssl') } + it { is_expected.not_to contain_concat__fragment('server1-800-rspec-test-ssl') } it { is_expected.not_to contain_file('/etc/nginx/rspec-test_htpasswd') } end - describe 'vhost/location_header template content' do + describe 'server/location_header template content' do [ { title: 'should set the location', @@ -175,13 +175,13 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', proxy: 'proxy_value', vhost: 'vhost1' } } + let(:default_params) { { location: 'location', proxy: 'proxy_value', server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -192,14 +192,14 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end end end - describe 'vhost/location_footer template content' do + describe 'server/location_footer template content' do [ { title: 'should contain ordered appended directives', @@ -252,13 +252,13 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', proxy: 'proxy_value', vhost: 'vhost1' } } + let(:default_params) { { location: 'location', proxy: 'proxy_value', server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -269,12 +269,12 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end it 'ends with a closing brace' do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) content = catalogue.resource('concat::fragment', fragment).send(:parameters)[:content] expect(content.split("\n").reject { |l| l =~ %r{^(\s*#|$)} }.last.strip).to eq('}') end @@ -282,45 +282,45 @@ end end - describe 'vhost_location_alias template content' do + describe 'server_location_alias template content' do let :default_params do - { location: 'location', vhost: 'vhost1', location_alias: 'value' } + { location: 'location', server: 'server1', location_alias: 'value' } end context "when location_alias is 'value'" do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'sets alias' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). with_content(%r{^[ ]+alias\s+value;}) end end context "when autoindex is 'on'" do let(:params) { default_params.merge(autoindex: 'on') } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'sets autoindex' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). with_content(%r{^[ ]+autoindex\s+on;}) end end context 'when autoindex is not set' do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'does not set autoindex' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). without_content(%r{^[ ]+autoindex[^;]+;}) end end end - describe 'vhost_location_directory template content' do + describe 'server_location_directory template content' do let :default_params do { location: 'location', www_root: '/var/www/root', - vhost: 'vhost1' + server: 'server1' } end @@ -347,9 +347,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -360,7 +360,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -368,24 +368,24 @@ context "when autoindex is 'on'" do let(:params) { default_params.merge(autoindex: 'on') } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'sets autoindex' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). with_content(%r{^[ ]+autoindex\s+on;}) end end context 'when autoindex is not set' do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')) } it 'does not set autoindex' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')). without_content(%r{^[ ]+autoindex[^;]+;}) end end end - describe 'vhost_location_empty template content' do + describe 'server_location_empty template content' do [ { title: 'should contain ordered config directives', @@ -405,12 +405,12 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', location_custom_cfg: { 'test1' => 'value1' }, vhost: 'vhost1' } } + let(:default_params) { { location: 'location', location_custom_cfg: { 'test1' => 'value1' }, server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -421,19 +421,19 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end end end - describe 'vhost_location_fastcgi template content' do + describe 'server_location_fastcgi template content' do let :default_params do { location: 'location', fastcgi: 'localhost:9000', - vhost: 'vhost1' + server: 'server1' } end @@ -472,9 +472,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -485,7 +485,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -493,18 +493,18 @@ context "when fastcgi_script is 'value'" do let(:params) { default_params.merge(fastcgi_script: 'value') } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it 'sets fastcgi_script' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{^[ ]+fastcgi_param\s+SCRIPT_FILENAME\s+value;}) end end context 'when fastcgi_script is not set' do let(:params) { default_params } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it 'does not set fastcgi_script' do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{^[ ]+fastcgi_param\s+SCRIPT_FILENAME\s+.+?;}) end end @@ -512,7 +512,7 @@ context "when fastcgi_param is {'CUSTOM_PARAM' => 'value'}" do let(:params) { default_params.merge(fastcgi_param: { 'CUSTOM_PARAM' => 'value', 'CUSTOM_PARAM2' => 'value2' }) } it 'sets fastcgi_param' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{fastcgi_param\s+CUSTOM_PARAM\s+value;}). with_content(%r{fastcgi_param\s+CUSTOM_PARAM2\s+value2;}) end @@ -521,7 +521,7 @@ context 'when fastcgi_param is {\'HTTP_PROXY\' => ""}' do let(:params) { default_params.merge(fastcgi_param: { 'HTTP_PROXY' => '""' }) } it 'sets fastcgi_param' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{fastcgi_param\s+HTTP_PROXY\s+"";}) end end @@ -529,23 +529,23 @@ context 'when fastcgi_param is not set' do let(:params) { default_params } it 'does not set fastcgi_param' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{fastcgi_param\s+CUSTOM_PARAM\s+.+?;}). without_content(%r{fastcgi_param\s+CUSTOM_PARAM2\s+.+?;}) end it 'does not add comment # Enable custom fastcgi_params' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{# Enable custom fastcgi_params\s+}) end end end - describe 'vhost_location_uwsgi template content' do + describe 'server_location_uwsgi template content' do let :default_params do { location: 'location', uwsgi: 'unix:/home/project/uwsgi.socket', - vhost: 'vhost1' + server: 'server1' } end @@ -584,9 +584,9 @@ context "when #{param[:attr]} is #{param[:value]}" do let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -597,7 +597,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -606,7 +606,7 @@ context "when uwsgi_param is {'CUSTOM_PARAM' => 'value'}" do let(:params) { default_params.merge(uwsgi_param: { 'CUSTOM_PARAM' => 'value', 'CUSTOM_PARAM2' => 'value2' }) } it 'sets uwsgi_param' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{uwsgi_param\s+CUSTOM_PARAM\s+value;}). with_content(%r{uwsgi_param\s+CUSTOM_PARAM2\s+value2;}) end @@ -615,7 +615,7 @@ context 'when uwsgi_param is {\'HTTP_PROXY\' => ""}' do let(:params) { default_params.merge(uwsgi_param: { 'HTTP_PROXY' => '""' }) } it 'sets uwsgi_param' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{uwsgi_param\s+HTTP_PROXY\s+"";}) end end @@ -623,13 +623,13 @@ context 'when uwsgi_param is not set' do let(:params) { default_params } it 'does not set uwsgi_param' do - should contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + should contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). without_content(%r{^\s+uwsgi_param\s+}) end end end - describe 'vhost_location_proxy template content' do + describe 'server_location_proxy template content' do [ { title: 'should set proxy_cache', @@ -753,12 +753,12 @@ } ].each do |param| context "when #{param[:attr]} is #{param[:value]}" do - let(:default_params) { { location: 'location', proxy: 'proxy_value', vhost: 'vhost1' } } + let(:default_params) { { location: 'location', proxy: 'proxy_value', server: 'server1' } } let(:params) { default_params.merge(param[:attr].to_sym => param[:value]) } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)) } it param[:title] do - fragment = 'vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s) + fragment = 'server1-500-' + Digest::MD5.hexdigest(params[:location].to_s) matches = Array(param[:match]) if matches.all? { |m| m.is_a? Regexp } @@ -769,7 +769,7 @@ end Array(param[:notmatch]).each do |item| - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)).without_content(item) end end end @@ -780,61 +780,61 @@ { location: 'location', proxy: 'proxy_value', - vhost: 'vhost1', + server: 'server1', proxy_cache: 'true', proxy_cache_valid: '10m' } end - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('location')).with_content(%r{proxy_cache_valid\s+10m;}) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('location')).with_content(%r{proxy_cache_valid\s+10m;}) } end end - describe 'vhost_location_stub_status template content' do - let(:params) { { location: 'location', stub_status: true, vhost: 'vhost1' } } + describe 'server_location_stub_status template content' do + let(:params) { { location: 'location', stub_status: true, server: 'server1' } } it do - is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). + is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest(params[:location].to_s)). with_content(%r{stub_status\s+on}) end end context 'attribute resources' do context 'when fastcgi => "localhost:9000"' do - let(:params) { { fastcgi: 'localhost:9000', vhost: 'vhost1' } } + let(:params) { { fastcgi: 'localhost:9000', server: 'server1' } } it { is_expected.to contain_file('/etc/nginx/fastcgi_params').with_mode('0770') } end context 'when uwsgi => "unix:/home/project/uwsgi.socket"' do - let(:params) { { uwsgi: 'uwsgi_upstream', vhost: 'vhost1' } } + let(:params) { { uwsgi: 'uwsgi_upstream', server: 'server1' } } it { should contain_file('/etc/nginx/uwsgi_params') } end context 'when ssl_only => true' do - let(:params) { { ssl_only: true, vhost: 'vhost1', www_root: '/' } } - it { is_expected.not_to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('rspec-test')) } + let(:params) { { ssl_only: true, server: 'server1', www_root: '/' } } + it { is_expected.not_to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('rspec-test')) } end context 'when ssl_only => false' do - let(:params) { { ssl_only: false, vhost: 'vhost1', www_root: '/' } } + let(:params) { { ssl_only: false, server: 'server1', www_root: '/' } } - it { is_expected.to contain_concat__fragment('vhost1-500-' + Digest::MD5.hexdigest('rspec-test')) } + it { is_expected.to contain_concat__fragment('server1-500-' + Digest::MD5.hexdigest('rspec-test')) } end context 'when ssl => true' do - let(:params) { { ssl: true, vhost: 'vhost1', www_root: '/' } } + let(:params) { { ssl: true, server: 'server1', www_root: '/' } } - it { is_expected.to contain_concat__fragment('vhost1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } + it { is_expected.to contain_concat__fragment('server1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } end context 'when ssl => false' do - let(:params) { { ssl: false, vhost: 'vhost1', www_root: '/' } } + let(:params) { { ssl: false, server: 'server1', www_root: '/' } } - it { is_expected.not_to contain_concat__fragment('vhost1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } + it { is_expected.not_to contain_concat__fragment('server1-800-' + Digest::MD5.hexdigest('rspec-test') + '-ssl') } end - context 'vhost missing' do + context 'server missing' do let :params do { www_root: '/' @@ -847,37 +847,37 @@ context 'location type missing' do let :params do { - vhost: 'vhost1' + server: 'server1' } end - it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in vhost1:rspec-test}) } + it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot create a location reference without a www_root, proxy, location_alias, stub_status, fastcgi, uwsgi, location_custom_cfg, internal, try_files, location_allow, or location_deny defined in server1:rspec-test}) } end context 'www_root and proxy are set' do let :params do { - vhost: 'vhost1', + server: 'server1', www_root: '/', proxy: 'http://localhost:8000/uri/' } end - it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot define both directory and proxy in vhost1:rspec-test}) } + it { expect { is_expected.to contain_class('nginx::resource::location') }.to raise_error(Puppet::Error, %r{Cannot define both directory and proxy in server1:rspec-test}) } end - context 'when vhost name is sanitized' do + context 'when server name is sanitized' do let(:title) { 'www.rspec-location.com' } let :params do { - vhost: 'www rspec-vhost com', + server: 'www rspec-server com', www_root: '/', ssl: true } end - it { is_expected.to contain_concat__fragment('www_rspec-vhost_com-500-' + Digest::MD5.hexdigest('www.rspec-location.com')).with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } - it { is_expected.to contain_concat__fragment('www_rspec-vhost_com-800-' + Digest::MD5.hexdigest('www.rspec-location.com') + '-ssl').with_target('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + it { is_expected.to contain_concat__fragment('www_rspec-server_com-500-' + Digest::MD5.hexdigest('www.rspec-location.com')).with_target('/etc/nginx/sites-available/www_rspec-server_com.conf') } + it { is_expected.to contain_concat__fragment('www_rspec-server_com-800-' + Digest::MD5.hexdigest('www.rspec-location.com') + '-ssl').with_target('/etc/nginx/sites-available/www_rspec-server_com.conf') } end end end diff --git a/spec/defines/resource_mailhost_spec.rb b/spec/defines/resource_mailhost_spec.rb index 5a8521c5e..f8099dbef 100644 --- a/spec/defines/resource_mailhost_spec.rb +++ b/spec/defines/resource_mailhost_spec.rb @@ -330,7 +330,7 @@ ) end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context 'SSL key missing and ssl => true' do @@ -339,7 +339,7 @@ ssl_cert: 'cert') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL cert missing and starttls => 'on'" do @@ -348,7 +348,7 @@ ssl_key: 'key') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL key missing and starttls => 'on'" do @@ -357,7 +357,7 @@ ssl_cert: 'cert') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL cert missing and starttls => 'only'" do @@ -366,7 +366,7 @@ ssl_key: 'key') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context "SSL key missing and starttls => 'only'" do @@ -375,7 +375,7 @@ ssl_cert: 'cert') end - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error, %r{nginx: SSL certificate/key \(ssl_cert/ssl_cert\) and/or SSL Private must be defined and exist on the target system\(s\)}) } end context 'when listen_port != ssl_port' do diff --git a/spec/defines/resource_stream_spec.rb b/spec/defines/resource_stream_spec.rb index cd94ef658..d2ad025b5 100644 --- a/spec/defines/resource_stream_spec.rb +++ b/spec/defines/resource_stream_spec.rb @@ -47,7 +47,7 @@ end end - describe 'vhost_header template content' do + describe 'server_header template content' do [ { title: 'should set the IPv4 listen IP', diff --git a/spec/defines/resource_vhost_spec.rb b/spec/defines/resource_vhost_spec.rb index b1c1193e7..a091c60f5 100644 --- a/spec/defines/resource_vhost_spec.rb +++ b/spec/defines/resource_vhost_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe 'nginx::resource::vhost' do +describe 'nginx::resource::server' do let :title do 'www.rspec.example.com' end @@ -56,7 +56,7 @@ end end - describe 'vhost_header template content' do + describe 'server_header template content' do [ { title: 'should not contain www to non-www rewrite', @@ -210,7 +210,7 @@ }, { title: 'should contain ordered prepended directives', - attr: 'vhost_cfg_prepend', + attr: 'server_cfg_prepend', value: { 'test1' => ['test value 1a', 'test value 1b'], 'test2' => 'test value 2', 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -283,7 +283,7 @@ match: ' access_log /var/log/nginx/www.rspec.example.com.access.log custom;' }, { - title: 'should not include access_log in vhost when set to absent', + title: 'should not include access_log in server when set to absent', attr: 'access_log', value: 'absent', notmatch: 'access_log' @@ -304,7 +304,7 @@ ] }, { - title: 'should not include error_log in vhost when set to absent', + title: 'should not include error_log in server when set to absent', attr: 'error_log', value: 'absent', notmatch: 'error_log' @@ -337,7 +337,7 @@ end end - describe 'vhost_footer template content' do + describe 'server_footer template content' do [ { title: 'should not contain www to non-www rewrite', @@ -360,7 +360,7 @@ }, { title: 'should contain ordered appended directives', - attr: 'vhost_cfg_append', + attr: 'server_cfg_append', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -401,7 +401,7 @@ end end - describe 'vhost_ssl_header template content' do + describe 'server_ssl_header template content' do [ { title: 'should not contain www to non-www rewrite', @@ -625,7 +625,7 @@ match: ' access_log off;' }, { - title: 'should not include access_log in vhost when set to absent', + title: 'should not include access_log in server when set to absent', attr: 'access_log', value: 'absent', notmatch: 'access_log' @@ -658,7 +658,7 @@ ] }, { - title: 'should not include error_log in vhost when set to absent', + title: 'should not include error_log in server when set to absent', attr: 'error_log', value: 'absent', notmatch: 'error_log' @@ -681,7 +681,7 @@ }, { title: 'should contain ordered prepend directives', - attr: 'vhost_cfg_prepend', + attr: 'server_cfg_prepend', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -692,7 +692,7 @@ }, { title: 'should contain ordered ssl prepend directives', - attr: 'vhost_cfg_ssl_prepend', + attr: 'server_cfg_ssl_prepend', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -739,7 +739,7 @@ end end - describe 'vhost_ssl_footer template content' do + describe 'server_ssl_footer template content' do [ { title: 'should not contain www to non-www rewrite', @@ -762,7 +762,7 @@ }, { title: 'should contain ordered appended directives', - attr: 'vhost_cfg_append', + attr: 'server_cfg_append', value: { 'test1' => 'test value 1', 'test2' => 'test value 2', 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -782,7 +782,7 @@ }, { title: 'should contain ordered ssl appended directives', - attr: 'vhost_cfg_ssl_append', + attr: 'server_cfg_ssl_append', value: { 'test1' => 'test value 1', 'test2' => ['test value 2a', 'test value 2b'], 'allow' => 'test value 3' }, match: [ ' allow test value 3;', @@ -855,13 +855,13 @@ context 'SSL cert missing' do let(:params) { { ssl: true, ssl_key: 'key' } } - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error) } end context 'SSL key missing' do let(:params) { { ssl: true, ssl_cert: 'cert' } } - it { expect { is_expected.to contain_class('nginx::resource::vhost') }.to raise_error(Puppet::Error) } + it { expect { is_expected.to contain_class('nginx::resource::server') }.to raise_error(Puppet::Error) } end context 'when use_default_location => true' do @@ -1090,11 +1090,11 @@ it { is_expected.to contain_concat__fragment("#{title}-footer").with_content(%r{passenger_pre_start http://example.com:80/test/me;}) } end - context 'when vhost name is sanitized' do - let(:title) { 'www rspec-vhost com' } + context 'when server name is sanitized' do + let(:title) { 'www rspec-server com' } let(:params) { default_params } - it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-vhost_com.conf') } + it { is_expected.to contain_concat('/etc/nginx/sites-available/www_rspec-server_com.conf') } end context 'when add_header is set' do diff --git a/templates/vhost/vhost_footer.erb b/templates/vhost/vhost_footer.erb index 4a543d829..c7dc1c4a1 100644 --- a/templates/vhost/vhost_footer.erb +++ b/templates/vhost/vhost_footer.erb @@ -6,8 +6,8 @@ <%# make sure that allow comes before deny by forcing the allow key (if it -%> <%# exists) to be first in the output order. The hash keys also need to be -%> <%# sorted so that the ordering is stable. -%> -<% if @vhost_cfg_append -%> - <%- @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_append -%> + <%- @server_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_header.erb b/templates/vhost/vhost_header.erb index 65c32fd86..cd157fe81 100644 --- a/templates/vhost/vhost_header.erb +++ b/templates/vhost/vhost_header.erb @@ -87,8 +87,8 @@ server { <%# make sure that allow comes before deny by forcing the allow key (if it -%> <%# exists) to be first in the output order. The hash keys also need to be -%> <%# sorted so that the ordering is stable. -%> -<% if @vhost_cfg_prepend -%> - <%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_prepend -%> + <%- @server_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_ssl_footer.erb b/templates/vhost/vhost_ssl_footer.erb index 90d0e4e85..343d0e8a0 100644 --- a/templates/vhost/vhost_ssl_footer.erb +++ b/templates/vhost/vhost_ssl_footer.erb @@ -3,8 +3,8 @@ include <%= file %>; <%- end -%> <% end -%> -<% if @vhost_cfg_append -%> - <%- @vhost_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_append -%> + <%- @server_cfg_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by{ |k, v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> @@ -18,8 +18,8 @@ <%- end -%> <%- end -%> <% end -%> -<% if @vhost_cfg_ssl_append -%> - <%- @vhost_cfg_ssl_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> +<% if @server_cfg_ssl_append -%> + <%- @server_cfg_ssl_append.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by{ |k, v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> diff --git a/templates/vhost/vhost_ssl_header.erb b/templates/vhost/vhost_ssl_header.erb index 382af3280..e3e865381 100644 --- a/templates/vhost/vhost_ssl_header.erb +++ b/templates/vhost/vhost_ssl_header.erb @@ -22,7 +22,7 @@ server { server_name www.<%= s.gsub(/^www\./, '') %>; return 301 https://<%= s.gsub(/^www\./, '') %>$request_uri; -<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %> +<%= scope.function_template(["nginx/server/server_ssl_settings.erb"]) %> } @@ -48,7 +48,7 @@ server { <%- end -%> server_name <%= @rewrite_www_to_non_www ? @server_name.join(" ").gsub(/(^| )(www\.)?(?=[a-z0-9])/, '') : @server_name.join(" ") %>; -<%= scope.function_template(["nginx/vhost/vhost_ssl_settings.erb"]) %> +<%= scope.function_template(["nginx/server/server_ssl_settings.erb"]) %> <% if @maintenance -%> <%= @maintenance_value %>; <% end -%> @@ -109,9 +109,9 @@ server { error_page <%= key %> <%= @error_pages[key] %>; <%- end -%> <% end -%> -<% if @vhost_cfg_prepend -%> +<% if @server_cfg_prepend -%> - <%- @vhost_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> + <%- @server_cfg_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%> @@ -125,9 +125,9 @@ server { <%- end -%> <%- end -%> <% end -%> -<% if @vhost_cfg_ssl_prepend -%> +<% if @server_cfg_ssl_prepend -%> - <%- @vhost_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> + <%- @server_cfg_ssl_prepend.sort_by{ |k, v| k.to_s == 'allow' ? '' : k.to_s }.each do |key,value| -%> <%- if value.is_a?(Hash) -%> <%- value.sort_by {|k,v| k}.each do |subkey,subvalue| -%> <%- Array(subvalue).each do |asubvalue| -%>