2011-12-13 23:49:18 +01:00
|
|
|
# define: nginx::resource::vhost
|
2011-06-07 01:05:27 +02:00
|
|
|
#
|
2011-12-13 23:49:18 +01:00
|
|
|
# This definition creates a virtual host
|
2011-06-07 01:05:27 +02:00
|
|
|
#
|
|
|
|
# Parameters:
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*ensure*] - Enables or disables the specified vhost
|
|
|
|
# (present|absent)
|
|
|
|
# [*listen_ip*] - Default IP Address for NGINX to listen with this
|
|
|
|
# vHost on. Defaults to all interfaces (*)
|
|
|
|
# [*listen_port*] - Default IP Port for NGINX to listen with this
|
|
|
|
# vHost on. Defaults to TCP 80
|
|
|
|
# [*listen_options*] - Extra options for listen directive like
|
2016-02-24 15:33:01 +01:00
|
|
|
# 'default_server' to catchall. Undef by default.
|
2015-10-30 20:14:47 +01:00
|
|
|
# [*listen_unix_socket_enable*] - BOOL value to enable/disable UNIX socket
|
|
|
|
# listening support (false|true).
|
|
|
|
# [*listen_unix_socket*] - Default unix socket for NGINX to listen with this
|
|
|
|
# vHost on. Defaults to UNIX /var/run/nginx.sock
|
|
|
|
# [*listen_unix_socket_options*] - Extra options for listen directive like
|
|
|
|
# 'default' to catchall. Undef by default.
|
2016-02-25 18:30:21 +01:00
|
|
|
# [*location_satisfy*] - Allows access if all (all) or at least one (any) of the auth modules allow access.
|
2013-09-04 19:04:28 +02:00
|
|
|
# [*location_allow*] - Array: Locations to allow connections from.
|
|
|
|
# [*location_deny*] - Array: Locations to deny connections from.
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*ipv6_enable*] - BOOL value to enable/disable IPv6 support
|
|
|
|
# (false|true). Module will check to see if IPv6 support exists on your
|
|
|
|
# system before enabling.
|
|
|
|
# [*ipv6_listen_ip*] - Default IPv6 Address for NGINX to listen with
|
|
|
|
# this vHost on. Defaults to all interfaces (::)
|
|
|
|
# [*ipv6_listen_port*] - Default IPv6 Port for NGINX to listen with this
|
|
|
|
# vHost on. Defaults to TCP 80
|
|
|
|
# [*ipv6_listen_options*] - Extra options for listen directive like 'default'
|
|
|
|
# to catchall. Template will allways add ipv6only=on. While issue
|
|
|
|
# jfryman/puppet-nginx#30 is discussed, default value is 'default'.
|
2013-12-24 19:47:15 +01:00
|
|
|
# [*add_header*] - Hash: Adds headers to the HTTP response when
|
2013-12-24 13:07:58 +01:00
|
|
|
# response code is equal to 200, 204, 301, 302 or 304.
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*index_files*] - Default index files for NGINX to read when
|
|
|
|
# traversing a directory
|
2014-02-10 18:14:18 +01:00
|
|
|
# [*autoindex*] - Set it on 'on' or 'off 'to activate/deactivate
|
|
|
|
# autoindex directory listing. Undef by default.
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*proxy*] - Proxy server(s) for the root location to connect
|
|
|
|
# to. Accepts a single value, can be used in conjunction with
|
|
|
|
# nginx::resource::upstream
|
|
|
|
# [*proxy_read_timeout*] - Override the default the proxy read timeout value
|
|
|
|
# of 90 seconds
|
2014-06-23 20:39:56 +02:00
|
|
|
# [*proxy_redirect*] - Override the default proxy_redirect value of off.
|
2014-04-03 11:59:47 +02:00
|
|
|
# [*resolver*] - Array: Configures name servers used to resolve
|
2013-12-29 15:48:32 +01:00
|
|
|
# names of upstream servers into addresses.
|
2013-03-20 18:44:45 +01:00
|
|
|
# [*fastcgi*] - location of fastcgi (host:port)
|
|
|
|
# [*fastcgi_params*] - optional alternative fastcgi_params file to use
|
|
|
|
# [*fastcgi_script*] - optional SCRIPT_FILE parameter
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*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.
|
2015-03-23 19:59:30 +01:00
|
|
|
# [*ssl_client_cert*] - Pre-generated SSL Certificate file to reference
|
|
|
|
# for client verify SSL Support. This is not generated by this module.
|
2016-04-11 13:35:19 +02:00
|
|
|
# [*ssl_verify_client*] - Enables verification of client certificates.
|
2015-04-14 20:28:19 +02:00
|
|
|
# [*ssl_crl*] - String: Specifies CRL path in file system
|
2013-12-27 09:10:11 +01:00
|
|
|
# [*ssl_dhparam*] - This directive specifies a file containing
|
|
|
|
# Diffie-Hellman key agreement protocol cryptographic parameters, in PEM
|
2014-01-27 16:57:38 +01:00
|
|
|
# format, utilized for exchanging session keys between server and client.
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*ssl_key*] - Pre-generated SSL Key file to reference for SSL
|
|
|
|
# Support. This is not generated by this module.
|
|
|
|
# [*ssl_port*] - Default IP Port for NGINX to listen with this SSL
|
|
|
|
# vHost on. Defaults to TCP 443
|
2014-10-15 19:52:31 +02:00
|
|
|
# [*ssl_protocols*] - SSL protocols enabled. Defaults to 'TLSv1 TLSv1.1
|
|
|
|
# TLSv1.2'.
|
2015-07-12 01:53:30 +02:00
|
|
|
# [*ssl_buffer_size*] - Sets the size of the buffer used for sending data.
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*ssl_ciphers*] - SSL ciphers enabled. Defaults to
|
2015-06-24 11:34:59 +02:00
|
|
|
# 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'.
|
2013-12-29 15:39:21 +01:00
|
|
|
# [*ssl_stapling*] - Bool: Enables or disables stapling of OCSP
|
|
|
|
# responses by the server. Defaults to false.
|
|
|
|
# [*ssl_stapling_file*] - String: When set, the stapled OCSP response
|
|
|
|
# will be taken from the specified file instead of querying the OCSP
|
|
|
|
# responder specified in the server certificate.
|
|
|
|
# [*ssl_stapling_responder*] - String: Overrides the URL of the OCSP
|
2013-12-30 19:03:55 +01:00
|
|
|
# responder specified in the Authority Information Access certificate
|
2013-12-29 15:39:21 +01:00
|
|
|
# extension.
|
|
|
|
# [*ssl_stapling_verify*] - Bool: Enables or disables verification of
|
|
|
|
# OCSP responses by the server. Defaults to false.
|
2014-08-20 13:56:44 +02:00
|
|
|
# [*ssl_session_timeout*] - String: Specifies a time during which a client
|
|
|
|
# may reuse the session parameters stored in a cache. Defaults to 5m.
|
2016-06-16 18:26:50 +02:00
|
|
|
# [*ssl_session_tickets*] - String: Enables or disables session resumption
|
|
|
|
# through TLS session tickets.
|
|
|
|
# [*ssl_session_ticket_key*] - String: Sets a file with the secret key used
|
|
|
|
# to encrypt and decrypt TLS session tickets.
|
2013-12-29 15:39:21 +01:00
|
|
|
# [*ssl_trusted_cert*] - String: Specifies a file with trusted CA
|
|
|
|
# certificates in the PEM format used to verify client certificates and
|
|
|
|
# OCSP responses if ssl_stapling is enabled.
|
2013-06-27 15:42:38 +02:00
|
|
|
# [*spdy*] - Toggles SPDY protocol.
|
2015-10-23 22:16:11 +02:00
|
|
|
# [*http2*] - Toggles HTTP/2 protocol.
|
2013-08-22 21:23:16 +02:00
|
|
|
# [*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
|
2013-05-21 15:15:59 +02:00
|
|
|
# [*rewrite_www_to_non_www*] - Adds a server directive and rewrite rule to
|
2013-08-22 21:23:16 +02:00
|
|
|
# rewrite www.domain.com to domain.com in order to avoid duplicate
|
|
|
|
# content (SEO);
|
2013-05-21 15:15:59 +02:00
|
|
|
# [*try_files*] - Specifies the locations for files to be
|
|
|
|
# checked as an array. Cannot be used in conjuction with $proxy.
|
|
|
|
# [*proxy_cache*] - This directive sets name of zone for caching.
|
|
|
|
# The same zone can be used in multiple places.
|
2015-05-29 23:21:34 +02:00
|
|
|
# [*proxy_cache_key*] - Override the default proxy_cache_key of
|
|
|
|
# $scheme$proxy_host$request_uri
|
|
|
|
# [*proxy_cache_use_stale*] - Override the default proxy_cache_use_stale value
|
|
|
|
# of off.
|
2013-05-21 15:15:59 +02:00
|
|
|
# [*proxy_cache_valid*] - This directive sets the time for caching
|
|
|
|
# different replies.
|
2013-10-15 22:49:33 +02:00
|
|
|
# [*proxy_method*] - If defined, overrides the HTTP method of the
|
|
|
|
# request to be passed to the backend.
|
2013-10-16 00:01:50 +02:00
|
|
|
# [*proxy_set_body*] - If defined, sets the body passed to the backend.
|
2013-05-21 15:15:59 +02:00
|
|
|
# [*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.
|
2014-01-28 21:52:56 +01:00
|
|
|
# [*client_max_body_size*] - This directive sets client_max_body_size.
|
2014-06-26 05:40:22 +02:00
|
|
|
# [*client_body_timeout*] - Sets how long the server will wait for a
|
2014-06-25 20:55:26 +02:00
|
|
|
# client body. Default is 60s
|
|
|
|
# [*client_header_timeout*] - Sets how long the server will wait for a
|
|
|
|
# client header. Default is 60s
|
2014-06-26 05:40:22 +02:00
|
|
|
# [*raw_prepend*] - A single string, or an array of strings to
|
|
|
|
# prepend to the server directive (after cfg prepend directives). NOTE:
|
|
|
|
# YOU are responsible for a semicolon on each line that requires one.
|
|
|
|
# [*raw_append*] - A single string, or an array of strings to
|
|
|
|
# append to the server directive (after cfg append directives). NOTE:
|
|
|
|
# YOU are responsible for a semicolon on each line that requires one.
|
|
|
|
# [*location_raw_prepend*] - A single string, or an array of strings
|
|
|
|
# to prepend to the location directive (after custom_cfg directives). NOTE:
|
|
|
|
# YOU are responsible for a semicolon on each line that requires one.
|
|
|
|
# [*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.
|
2013-05-21 15:15:59 +02:00
|
|
|
# [*vhost_cfg_append*] - It expects a hash with custom directives to
|
|
|
|
# put after everything else inside vhost
|
2013-08-22 21:02:04 +02:00
|
|
|
# [*vhost_cfg_prepend*] - It expects a hash with custom directives to
|
|
|
|
# put before everything else inside vhost
|
2014-02-08 00:40:52 +01:00
|
|
|
# [*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
|
2013-05-21 15:15:59 +02:00
|
|
|
# [*rewrite_to_https*] - Adds a server directive and rewrite rule to
|
2014-04-18 11:57:31 +02:00
|
|
|
# rewrite to ssl
|
2013-06-13 18:44:15 +02:00
|
|
|
# [*include_files*] - Adds include files to vhost
|
2013-08-07 16:19:46 +02:00
|
|
|
# [*access_log*] - Where to write access log. May add additional
|
2014-04-18 11:57:31 +02:00
|
|
|
# options like log format to the end.
|
2013-08-07 16:19:46 +02:00
|
|
|
# [*error_log*] - Where to write error log. May add additional
|
2014-04-18 11:57:31 +02:00
|
|
|
# options like error level to the end.
|
2013-12-12 17:27:29 +01:00
|
|
|
# [*passenger_cgi_param*] - Allows one to define additional CGI environment
|
2014-04-18 11:57:31 +02:00
|
|
|
# variables to pass to the backend application
|
2015-04-29 23:37:58 +02:00
|
|
|
# [*passenger_set_header*] - Allows one to set headers to pass to the
|
2015-04-29 18:24:38 +02:00
|
|
|
# backend application (Passenger 5.0+)
|
2015-04-29 18:33:42 +02:00
|
|
|
# [*passenger_env_var*] - Allows one to set environemnt variables to pass
|
|
|
|
# to the backend application (Passenger 5.0+)
|
2014-04-18 11:57:31 +02:00
|
|
|
# [*log_by_lua*] - Run the Lua source code inlined as the
|
|
|
|
# <lua-script-str> at the log request processing phase.
|
|
|
|
# This does not replace the current access logs, but runs after.
|
|
|
|
# [*log_by_lua_file*] - Equivalent to log_by_lua, except that the file
|
|
|
|
# specified by <path-to-lua-script-file> contains the Lua code, or, as from
|
|
|
|
# the v0.5.0rc32 release, the Lua/LuaJIT bytecode to be executed.
|
2014-06-25 22:58:55 +02:00
|
|
|
# [*gzip_types*] - Defines gzip_types, nginx default is text/html
|
2014-07-03 16:06:54 +02:00
|
|
|
# [*owner*] - Defines owner of the .conf file
|
|
|
|
# [*group*] - Defines group of the .conf file
|
|
|
|
# [*mode*] - Defines mode of the .conf file
|
2015-03-24 15:45:29 +01:00
|
|
|
# [*maintenance*] - A boolean value to set a vhost in maintenance
|
|
|
|
# [*maintenance_value*] - Value to return when maintenance is on.
|
|
|
|
# Default to return 503
|
2016-01-17 15:48:38 +01:00
|
|
|
# [*locations*] - Hash of vhosts ressources used by this vhost
|
2011-06-07 01:05:27 +02:00
|
|
|
# Actions:
|
|
|
|
#
|
|
|
|
# Requires:
|
|
|
|
#
|
|
|
|
# Sample Usage:
|
|
|
|
# nginx::resource::vhost { 'test2.local':
|
|
|
|
# ensure => present,
|
|
|
|
# www_root => '/var/www/nginx-default',
|
2013-05-26 14:24:40 +02:00
|
|
|
# ssl => true,
|
2011-06-07 01:05:27 +02:00
|
|
|
# ssl_cert => '/tmp/server.crt',
|
|
|
|
# ssl_key => '/tmp/server.pem',
|
|
|
|
# }
|
2013-04-13 13:52:21 +02:00
|
|
|
define nginx::resource::vhost (
|
2014-11-22 19:40:01 +01:00
|
|
|
$ensure = 'present',
|
|
|
|
$listen_ip = '*',
|
2016-03-04 13:54:48 +01:00
|
|
|
$listen_port = 80,
|
2014-11-22 19:40:01 +01:00
|
|
|
$listen_options = undef,
|
2015-10-30 20:14:47 +01:00
|
|
|
$listen_unix_socket_enable = false,
|
|
|
|
$listen_unix_socket = '/var/run/nginx.sock',
|
|
|
|
$listen_unix_socket_options = undef,
|
2016-02-25 18:30:21 +01:00
|
|
|
$location_satisfy = undef,
|
2014-11-22 19:40:01 +01:00
|
|
|
$location_allow = [],
|
|
|
|
$location_deny = [],
|
|
|
|
$ipv6_enable = false,
|
|
|
|
$ipv6_listen_ip = '::',
|
2016-03-04 13:54:48 +01:00
|
|
|
$ipv6_listen_port = 80,
|
2014-11-22 19:40:01 +01:00
|
|
|
$ipv6_listen_options = 'default ipv6only=on',
|
|
|
|
$add_header = undef,
|
|
|
|
$ssl = false,
|
|
|
|
$ssl_listen_option = true,
|
|
|
|
$ssl_cert = undef,
|
2015-03-23 19:59:30 +01:00
|
|
|
$ssl_client_cert = undef,
|
2016-04-11 13:35:19 +02:00
|
|
|
$ssl_verify_client = 'on',
|
2014-11-22 19:40:01 +01:00
|
|
|
$ssl_dhparam = undef,
|
|
|
|
$ssl_key = undef,
|
2016-03-04 13:54:48 +01:00
|
|
|
$ssl_port = 443,
|
2014-11-22 19:40:01 +01:00
|
|
|
$ssl_protocols = 'TLSv1 TLSv1.1 TLSv1.2',
|
2015-07-12 01:53:30 +02:00
|
|
|
$ssl_buffer_size = undef,
|
2015-06-24 11:34:59 +02:00
|
|
|
$ssl_ciphers = 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA',
|
2014-11-22 19:40:01 +01:00
|
|
|
$ssl_cache = 'shared:SSL:10m',
|
2015-04-14 20:28:19 +02:00
|
|
|
$ssl_crl = undef,
|
2014-11-22 19:40:01 +01:00
|
|
|
$ssl_stapling = false,
|
|
|
|
$ssl_stapling_file = undef,
|
|
|
|
$ssl_stapling_responder = undef,
|
|
|
|
$ssl_stapling_verify = false,
|
|
|
|
$ssl_session_timeout = '5m',
|
2016-06-16 18:26:50 +02:00
|
|
|
$ssl_session_tickets = undef,
|
|
|
|
$ssl_session_ticket_key = undef,
|
2014-11-22 19:40:01 +01:00
|
|
|
$ssl_trusted_cert = undef,
|
2014-11-27 05:33:57 +01:00
|
|
|
$spdy = $::nginx::config::spdy,
|
2015-10-23 22:16:11 +02:00
|
|
|
$http2 = $::nginx::config::http2,
|
2014-11-22 19:40:01 +01:00
|
|
|
$proxy = undef,
|
|
|
|
$proxy_redirect = undef,
|
2014-11-27 05:33:57 +01:00
|
|
|
$proxy_read_timeout = $::nginx::config::proxy_read_timeout,
|
|
|
|
$proxy_connect_timeout = $::nginx::config::proxy_connect_timeout,
|
2015-10-19 16:47:51 +02:00
|
|
|
$proxy_set_header = $::nginx::config::proxy_set_header,
|
2016-05-12 18:09:16 +02:00
|
|
|
$proxy_hide_header = $::nginx::config::proxy_hide_header,
|
2014-11-22 19:40:01 +01:00
|
|
|
$proxy_cache = false,
|
2015-05-29 23:21:34 +02:00
|
|
|
$proxy_cache_key = undef,
|
|
|
|
$proxy_cache_use_stale = undef,
|
2014-11-22 19:40:01 +01:00
|
|
|
$proxy_cache_valid = false,
|
|
|
|
$proxy_method = undef,
|
|
|
|
$proxy_set_body = undef,
|
|
|
|
$resolver = [],
|
|
|
|
$fastcgi = undef,
|
2014-11-27 05:33:57 +01:00
|
|
|
$fastcgi_params = "${::nginx::config::conf_dir}/fastcgi_params",
|
2014-11-22 19:40:01 +01:00
|
|
|
$fastcgi_script = undef,
|
2015-05-08 11:11:46 +02:00
|
|
|
$uwsgi = undef,
|
|
|
|
$uwsgi_params = "${nginx::config::conf_dir}/uwsgi_params",
|
2014-11-22 19:40:01 +01:00
|
|
|
$index_files = [
|
2013-04-13 13:52:21 +02:00
|
|
|
'index.html',
|
|
|
|
'index.htm',
|
|
|
|
'index.php'],
|
2014-11-22 19:40:01 +01:00
|
|
|
$autoindex = undef,
|
|
|
|
$server_name = [$name],
|
|
|
|
$www_root = undef,
|
|
|
|
$rewrite_www_to_non_www = false,
|
|
|
|
$rewrite_to_https = undef,
|
|
|
|
$location_custom_cfg = undef,
|
|
|
|
$location_cfg_prepend = undef,
|
|
|
|
$location_cfg_append = undef,
|
2014-04-11 17:55:16 +02:00
|
|
|
$location_custom_cfg_prepend = undef,
|
|
|
|
$location_custom_cfg_append = undef,
|
2014-11-22 19:40:01 +01:00
|
|
|
$try_files = undef,
|
|
|
|
$auth_basic = undef,
|
|
|
|
$auth_basic_user_file = undef,
|
|
|
|
$client_body_timeout = undef,
|
|
|
|
$client_header_timeout = undef,
|
|
|
|
$client_max_body_size = undef,
|
|
|
|
$raw_prepend = undef,
|
|
|
|
$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,
|
|
|
|
$include_files = undef,
|
|
|
|
$access_log = undef,
|
|
|
|
$error_log = undef,
|
2014-11-26 05:38:05 +01:00
|
|
|
$format_log = 'combined',
|
2014-11-22 19:40:01 +01:00
|
|
|
$passenger_cgi_param = undef,
|
2015-04-29 23:37:58 +02:00
|
|
|
$passenger_set_header = undef,
|
2015-04-29 18:33:42 +02:00
|
|
|
$passenger_env_var = undef,
|
2014-11-22 19:40:01 +01:00
|
|
|
$log_by_lua = undef,
|
|
|
|
$log_by_lua_file = undef,
|
|
|
|
$use_default_location = true,
|
|
|
|
$rewrite_rules = [],
|
|
|
|
$string_mappings = {},
|
|
|
|
$geo_mappings = {},
|
|
|
|
$gzip_types = undef,
|
2014-11-27 05:33:57 +01:00
|
|
|
$owner = $::nginx::config::global_owner,
|
|
|
|
$group = $::nginx::config::global_group,
|
|
|
|
$mode = $::nginx::config::global_mode,
|
2015-03-17 17:06:54 +01:00
|
|
|
$maintenance = false,
|
2016-01-17 15:48:38 +01:00
|
|
|
$maintenance_value = 'return 503',
|
|
|
|
$locations = {}
|
2011-06-07 00:25:04 +02:00
|
|
|
) {
|
2011-06-15 21:40:42 +02:00
|
|
|
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_re($ensure, '^(present|absent)$',
|
|
|
|
"${ensure} is not supported for ensure. Allowed values are 'present' and 'absent'.")
|
2015-01-13 17:30:00 +01:00
|
|
|
if !(is_array($listen_ip) or is_string($listen_ip)) {
|
|
|
|
fail('$listen_ip must be a string or array.')
|
|
|
|
}
|
2016-03-04 13:54:48 +01:00
|
|
|
if is_string($listen_port) {
|
|
|
|
warning('DEPRECATION: String $listen_port must be converted to an integer. Integer string support will be removed in a future release.')
|
|
|
|
}
|
|
|
|
elsif !is_integer($listen_port) {
|
2014-01-06 19:47:33 +01:00
|
|
|
fail('$listen_port must be an integer.')
|
|
|
|
}
|
|
|
|
if ($listen_options != undef) {
|
|
|
|
validate_string($listen_options)
|
|
|
|
}
|
2015-10-30 20:14:47 +01:00
|
|
|
validate_bool($listen_unix_socket_enable)
|
|
|
|
if !(is_array($listen_unix_socket) or is_string($listen_unix_socket)) {
|
|
|
|
fail('$listen_unix_socket must be a string or array.')
|
|
|
|
}
|
|
|
|
if ($listen_unix_socket_options != undef) {
|
|
|
|
validate_string($listen_unix_socket_options)
|
|
|
|
}
|
2016-02-25 18:30:21 +01:00
|
|
|
if ($location_satisfy != undef) {
|
|
|
|
validate_re($location_satisfy, '^(any|all)$',
|
|
|
|
"${$location_satisfy} is not supported for location_satisfy. Allowed values are 'any' and 'all'.")
|
|
|
|
}
|
2013-09-04 19:04:28 +02:00
|
|
|
validate_array($location_allow)
|
|
|
|
validate_array($location_deny)
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_bool($ipv6_enable)
|
2015-01-13 17:30:00 +01:00
|
|
|
if !(is_array($ipv6_listen_ip) or is_string($ipv6_listen_ip)) {
|
|
|
|
fail('$ipv6_listen_ip must be a string or array.')
|
|
|
|
}
|
2016-03-04 13:54:48 +01:00
|
|
|
if is_string($ipv6_listen_port) {
|
|
|
|
warning('DEPRECATION: String $ipv6_listen_port must be converted to an integer. Integer string support will be removed in a future release.')
|
|
|
|
}
|
|
|
|
elsif !is_integer($ipv6_listen_port) {
|
2014-01-06 19:47:33 +01:00
|
|
|
fail('$ipv6_listen_port must be an integer.')
|
|
|
|
}
|
|
|
|
validate_string($ipv6_listen_options)
|
2013-12-24 19:47:15 +01:00
|
|
|
if ($add_header != undef) {
|
|
|
|
validate_hash($add_header)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_bool($ssl)
|
|
|
|
if ($ssl_cert != undef) {
|
|
|
|
validate_string($ssl_cert)
|
|
|
|
}
|
2015-03-23 19:59:30 +01:00
|
|
|
if ($ssl_client_cert != undef) {
|
2015-03-23 20:14:15 +01:00
|
|
|
validate_string($ssl_client_cert)
|
2015-03-23 19:59:30 +01:00
|
|
|
}
|
2016-04-11 13:35:19 +02:00
|
|
|
if ($ssl_verify_client != undef) {
|
|
|
|
validate_string($ssl_verify_client)
|
|
|
|
}
|
2015-04-14 20:28:19 +02:00
|
|
|
if ($ssl_crl != undef) {
|
|
|
|
validate_string($ssl_crl)
|
|
|
|
}
|
2014-06-02 00:23:07 +02:00
|
|
|
validate_bool($ssl_listen_option)
|
2013-12-27 09:10:11 +01:00
|
|
|
if ($ssl_dhparam != undef) {
|
|
|
|
validate_string($ssl_dhparam)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
if ($ssl_key != undef) {
|
|
|
|
validate_string($ssl_key)
|
|
|
|
}
|
2016-03-04 13:54:48 +01:00
|
|
|
if is_string($ssl_port) {
|
|
|
|
warning('DEPRECATION: String $ssl_port must be converted to an integer. Integer string support will be removed in a future release.')
|
|
|
|
}
|
|
|
|
elsif !is_integer($ssl_port) {
|
2014-01-06 19:47:33 +01:00
|
|
|
fail('$ssl_port must be an integer.')
|
2013-12-29 15:48:32 +01:00
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_string($ssl_protocols)
|
|
|
|
validate_string($ssl_ciphers)
|
|
|
|
validate_string($ssl_cache)
|
2013-12-29 15:39:21 +01:00
|
|
|
validate_bool($ssl_stapling)
|
|
|
|
if ($ssl_stapling_file != undef) {
|
|
|
|
validate_string($ssl_stapling_file)
|
|
|
|
}
|
|
|
|
if ($ssl_stapling_responder != undef) {
|
|
|
|
validate_string($ssl_stapling_responder)
|
|
|
|
}
|
|
|
|
validate_bool($ssl_stapling_verify)
|
2014-08-20 13:56:44 +02:00
|
|
|
validate_string($ssl_session_timeout)
|
2016-06-16 18:26:50 +02:00
|
|
|
if ($ssl_session_tickets) {
|
|
|
|
validate_string($ssl_session_tickets)
|
|
|
|
}
|
|
|
|
if ($ssl_session_ticket_key) {
|
|
|
|
validate_string($ssl_session_ticket_key)
|
|
|
|
}
|
2013-12-29 15:39:21 +01:00
|
|
|
if ($ssl_trusted_cert != undef) {
|
|
|
|
validate_string($ssl_trusted_cert)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_string($spdy)
|
|
|
|
if ($proxy != undef) {
|
|
|
|
validate_string($proxy)
|
|
|
|
}
|
|
|
|
validate_string($proxy_read_timeout)
|
2014-09-24 02:06:15 +02:00
|
|
|
if ($proxy_redirect != undef) {
|
|
|
|
validate_string($proxy_redirect)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_array($proxy_set_header)
|
2016-05-12 18:09:16 +02:00
|
|
|
validate_array($proxy_hide_header)
|
2014-01-06 19:47:33 +01:00
|
|
|
if ($proxy_cache != false) {
|
|
|
|
validate_string($proxy_cache)
|
|
|
|
}
|
2015-05-29 23:21:34 +02:00
|
|
|
if ($proxy_cache_key != undef) {
|
|
|
|
validate_string($proxy_cache_key)
|
|
|
|
}
|
|
|
|
if ($proxy_cache_use_stale != undef) {
|
|
|
|
validate_string($proxy_cache_use_stale)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
if ($proxy_cache_valid != false) {
|
2016-04-12 10:02:08 +02:00
|
|
|
if !(is_array($proxy_cache_valid) or is_string($proxy_cache_valid)) {
|
|
|
|
fail('$proxy_cache_valid must be a string or an array or false.')
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
}
|
|
|
|
if ($proxy_method != undef) {
|
|
|
|
validate_string($proxy_method)
|
|
|
|
}
|
|
|
|
if ($proxy_set_body != undef) {
|
|
|
|
validate_string($proxy_set_body)
|
|
|
|
}
|
2014-04-03 11:59:47 +02:00
|
|
|
validate_array($resolver)
|
2014-01-06 19:47:33 +01:00
|
|
|
if ($fastcgi != undef) {
|
|
|
|
validate_string($fastcgi)
|
|
|
|
}
|
|
|
|
validate_string($fastcgi_params)
|
|
|
|
if ($fastcgi_script != undef) {
|
|
|
|
validate_string($fastcgi_script)
|
|
|
|
}
|
2014-06-24 18:17:08 +02:00
|
|
|
if ($uwsgi != undef) {
|
|
|
|
validate_string($uwsgi)
|
|
|
|
}
|
2014-06-24 19:05:10 +02:00
|
|
|
validate_string($uwsgi_params)
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_array($index_files)
|
|
|
|
if ($autoindex != undef) {
|
|
|
|
validate_string($autoindex)
|
|
|
|
}
|
|
|
|
validate_array($server_name)
|
|
|
|
if ($www_root != undef) {
|
|
|
|
validate_string($www_root)
|
|
|
|
}
|
|
|
|
validate_bool($rewrite_www_to_non_www)
|
|
|
|
if ($rewrite_to_https != undef) {
|
|
|
|
validate_bool($rewrite_to_https)
|
|
|
|
}
|
2014-06-26 05:40:22 +02:00
|
|
|
if ($raw_prepend != undef) {
|
|
|
|
if (is_array($raw_prepend)) {
|
|
|
|
validate_array($raw_prepend)
|
|
|
|
} else {
|
|
|
|
validate_string($raw_prepend)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($raw_append != undef) {
|
|
|
|
if (is_array($raw_append)) {
|
|
|
|
validate_array($raw_append)
|
|
|
|
} else {
|
|
|
|
validate_string($raw_append)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($location_raw_prepend != undef) {
|
|
|
|
if (is_array($location_raw_prepend)) {
|
|
|
|
validate_array($location_raw_prepend)
|
|
|
|
} else {
|
|
|
|
validate_string($location_raw_prepend)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($location_raw_append != undef) {
|
|
|
|
if (is_array($location_raw_append)) {
|
|
|
|
validate_array($location_raw_append)
|
|
|
|
} else {
|
|
|
|
validate_string($location_raw_append)
|
|
|
|
}
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
if ($location_custom_cfg != undef) {
|
|
|
|
validate_hash($location_custom_cfg)
|
|
|
|
}
|
|
|
|
if ($location_cfg_prepend != undef) {
|
|
|
|
validate_hash($location_cfg_prepend)
|
|
|
|
}
|
|
|
|
if ($location_cfg_append != undef) {
|
|
|
|
validate_hash($location_cfg_append)
|
|
|
|
}
|
|
|
|
if ($try_files != undef) {
|
|
|
|
validate_array($try_files)
|
|
|
|
}
|
|
|
|
if ($auth_basic != undef) {
|
|
|
|
validate_string($auth_basic)
|
|
|
|
}
|
|
|
|
if ($auth_basic_user_file != undef) {
|
|
|
|
validate_string($auth_basic_user_file)
|
|
|
|
}
|
|
|
|
if ($vhost_cfg_prepend != undef) {
|
|
|
|
validate_hash($vhost_cfg_prepend)
|
|
|
|
}
|
|
|
|
if ($vhost_cfg_append != undef) {
|
|
|
|
validate_hash($vhost_cfg_append)
|
|
|
|
}
|
2014-02-08 00:40:52 +01:00
|
|
|
if ($vhost_cfg_ssl_prepend != undef) {
|
|
|
|
validate_hash($vhost_cfg_ssl_prepend)
|
|
|
|
}
|
|
|
|
if ($vhost_cfg_ssl_append != undef) {
|
|
|
|
validate_hash($vhost_cfg_ssl_append)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
if ($include_files != undef) {
|
|
|
|
validate_array($include_files)
|
|
|
|
}
|
|
|
|
if ($access_log != undef) {
|
|
|
|
validate_string($access_log)
|
|
|
|
}
|
|
|
|
if ($error_log != undef) {
|
|
|
|
validate_string($error_log)
|
|
|
|
}
|
|
|
|
if ($passenger_cgi_param != undef) {
|
|
|
|
validate_hash($passenger_cgi_param)
|
|
|
|
}
|
2015-04-29 23:37:58 +02:00
|
|
|
if ($passenger_set_header != undef) {
|
|
|
|
validate_hash($passenger_set_header)
|
2015-04-29 18:24:38 +02:00
|
|
|
}
|
2015-04-29 18:33:42 +02:00
|
|
|
if ($passenger_env_var != undef) {
|
|
|
|
validate_hash($passenger_env_var)
|
|
|
|
}
|
2014-04-18 11:57:31 +02:00
|
|
|
if ($log_by_lua != undef) {
|
|
|
|
validate_string($log_by_lua)
|
|
|
|
}
|
|
|
|
if ($log_by_lua_file != undef) {
|
|
|
|
validate_string($log_by_lua_file)
|
|
|
|
}
|
2014-06-25 20:55:26 +02:00
|
|
|
if ($client_body_timeout != undef) {
|
|
|
|
validate_string($client_body_timeout)
|
|
|
|
}
|
|
|
|
if ($client_header_timeout != undef) {
|
|
|
|
validate_string($client_header_timeout)
|
|
|
|
}
|
2014-06-25 22:58:55 +02:00
|
|
|
if ($gzip_types != undef) {
|
|
|
|
validate_string($gzip_types)
|
|
|
|
}
|
2014-01-06 19:47:33 +01:00
|
|
|
validate_bool($use_default_location)
|
2014-01-13 19:20:02 +01:00
|
|
|
validate_array($rewrite_rules)
|
2014-06-12 20:12:24 +02:00
|
|
|
validate_hash($string_mappings)
|
|
|
|
validate_hash($geo_mappings)
|
2016-01-17 15:48:38 +01:00
|
|
|
validate_hash($locations)
|
2013-09-04 19:04:28 +02:00
|
|
|
|
2014-07-03 16:06:54 +02:00
|
|
|
validate_string($owner)
|
|
|
|
validate_string($group)
|
|
|
|
validate_re($mode, '^\d{4}$',
|
|
|
|
"${mode} is not valid. It should be 4 digits (0644 by default).")
|
|
|
|
|
2013-12-01 01:51:31 +01:00
|
|
|
# Variables
|
2014-11-27 05:33:57 +01:00
|
|
|
$vhost_dir = "${::nginx::config::conf_dir}/sites-available"
|
|
|
|
$vhost_enable_dir = "${::nginx::config::conf_dir}/sites-enabled"
|
2013-12-01 01:51:31 +01:00
|
|
|
$vhost_symlink_ensure = $ensure ? {
|
|
|
|
'absent' => absent,
|
|
|
|
default => 'link',
|
|
|
|
}
|
2013-12-24 18:22:32 +01:00
|
|
|
|
|
|
|
$name_sanitized = regsubst($name, ' ', '_', 'G')
|
|
|
|
$config_file = "${vhost_dir}/${name_sanitized}.conf"
|
2013-12-01 01:51:31 +01:00
|
|
|
|
2011-06-15 21:40:42 +02:00
|
|
|
File {
|
2013-04-13 19:39:52 +02:00
|
|
|
ensure => $ensure ? {
|
|
|
|
'absent' => absent,
|
|
|
|
default => 'file',
|
|
|
|
},
|
2014-11-27 05:33:57 +01:00
|
|
|
notify => Class['::nginx::service'],
|
2014-07-03 16:06:54 +02:00
|
|
|
owner => $owner,
|
|
|
|
group => $group,
|
|
|
|
mode => $mode,
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Add IPv6 Logic Check - Nginx service will not start if ipv6 is enabled
|
|
|
|
# and support does not exist for it in the kernel.
|
2014-07-18 04:00:16 +02:00
|
|
|
if ($ipv6_enable == true) and (!$::ipaddress6) {
|
2011-06-15 21:40:42 +02:00
|
|
|
warning('nginx: IPv6 support is not enabled or configured properly')
|
|
|
|
}
|
|
|
|
|
|
|
|
# Check to see if SSL Certificates are properly defined.
|
2013-04-13 19:39:52 +02:00
|
|
|
if ($ssl == true) {
|
2011-06-15 21:40:42 +02:00
|
|
|
if ($ssl_cert == undef) or ($ssl_key == undef) {
|
2014-05-29 15:23:57 +02:00
|
|
|
fail('nginx: SSL certificate/key (ssl_cert/ssl_key) and/or SSL Private must be defined and exist on the target system(s)')
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-07 02:40:21 +02:00
|
|
|
# This was a lot to add up in parameter list so add it down here
|
|
|
|
# Also opted to add more logic here and keep template cleaner which
|
|
|
|
# unfortunately means resorting to the $varname_real thing
|
2014-11-26 05:38:05 +01:00
|
|
|
$access_log_real = $access_log ? {
|
|
|
|
'off' => 'off',
|
2014-11-27 05:33:57 +01:00
|
|
|
undef => "${::nginx::config::log_dir}/${name_sanitized}.access.log ${format_log}",
|
2014-11-26 05:38:05 +01:00
|
|
|
default => "${access_log} ${format_log}",
|
2014-04-11 18:04:24 +02:00
|
|
|
}
|
2014-04-11 17:55:16 +02:00
|
|
|
|
2013-08-07 02:40:21 +02:00
|
|
|
$error_log_real = $error_log ? {
|
2014-11-27 05:33:57 +01:00
|
|
|
undef => "${::nginx::config::log_dir}/${name_sanitized}.error.log",
|
2013-08-07 02:40:21 +02:00
|
|
|
default => $error_log,
|
|
|
|
}
|
|
|
|
|
2013-12-01 01:51:31 +01:00
|
|
|
concat { $config_file:
|
2015-06-13 04:05:09 +02:00
|
|
|
owner => $owner,
|
|
|
|
group => $group,
|
|
|
|
mode => $mode,
|
|
|
|
notify => Class['::nginx::service'],
|
2013-12-01 01:51:31 +01:00
|
|
|
}
|
|
|
|
|
2016-03-04 13:54:48 +01:00
|
|
|
$ssl_only = ($ssl == true) and (($ssl_port + 0) == ($listen_port + 0))
|
2013-12-12 17:27:29 +01:00
|
|
|
|
2013-09-29 20:53:25 +02:00
|
|
|
if $use_default_location == true {
|
|
|
|
# Create the default location reference for the vHost
|
2015-08-07 14:29:23 +02:00
|
|
|
nginx::resource::location {"${name_sanitized}-default":
|
2015-05-20 12:38:20 +02:00
|
|
|
ensure => $ensure,
|
|
|
|
vhost => $name_sanitized,
|
|
|
|
ssl => $ssl,
|
|
|
|
ssl_only => $ssl_only,
|
|
|
|
location => '/',
|
2016-02-25 18:30:21 +01:00
|
|
|
location_satisfy => $location_satisfy,
|
2015-05-20 12:38:20 +02:00
|
|
|
location_allow => $location_allow,
|
|
|
|
location_deny => $location_deny,
|
|
|
|
proxy => $proxy,
|
|
|
|
proxy_redirect => $proxy_redirect,
|
|
|
|
proxy_read_timeout => $proxy_read_timeout,
|
|
|
|
proxy_connect_timeout => $proxy_connect_timeout,
|
|
|
|
proxy_cache => $proxy_cache,
|
2015-05-29 23:21:34 +02:00
|
|
|
proxy_cache_key => $proxy_cache_key,
|
|
|
|
proxy_cache_use_stale => $proxy_cache_use_stale,
|
2015-05-20 12:38:20 +02:00
|
|
|
proxy_cache_valid => $proxy_cache_valid,
|
|
|
|
proxy_method => $proxy_method,
|
|
|
|
proxy_set_header => $proxy_set_header,
|
2016-05-12 18:09:16 +02:00
|
|
|
proxy_hide_header => $proxy_hide_header,
|
2015-05-20 12:38:20 +02:00
|
|
|
proxy_set_body => $proxy_set_body,
|
|
|
|
fastcgi => $fastcgi,
|
|
|
|
fastcgi_params => $fastcgi_params,
|
|
|
|
fastcgi_script => $fastcgi_script,
|
|
|
|
uwsgi => $uwsgi,
|
|
|
|
uwsgi_params => $uwsgi_params,
|
|
|
|
try_files => $try_files,
|
|
|
|
www_root => $www_root,
|
|
|
|
autoindex => $autoindex,
|
|
|
|
index_files => $index_files,
|
|
|
|
location_custom_cfg => $location_custom_cfg,
|
|
|
|
location_cfg_prepend => $location_cfg_prepend,
|
|
|
|
location_cfg_append => $location_cfg_append,
|
|
|
|
location_custom_cfg_prepend => $location_custom_cfg_prepend,
|
|
|
|
location_custom_cfg_append => $location_custom_cfg_append,
|
|
|
|
rewrite_rules => $rewrite_rules,
|
|
|
|
raw_prepend => $location_raw_prepend,
|
|
|
|
raw_append => $location_raw_append,
|
|
|
|
notify => Class['nginx::service'],
|
2013-09-29 20:53:25 +02:00
|
|
|
}
|
2014-04-12 00:12:54 +02:00
|
|
|
$root = undef
|
2013-09-29 20:53:25 +02:00
|
|
|
} else {
|
|
|
|
$root = $www_root
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
2014-06-13 12:29:02 +02:00
|
|
|
if $fastcgi != undef and !defined(File[$fastcgi_params]) {
|
|
|
|
file { $fastcgi_params:
|
2013-07-31 23:07:59 +02:00
|
|
|
ensure => present,
|
|
|
|
mode => '0770',
|
|
|
|
content => template('nginx/vhost/fastcgi_params.erb'),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-24 19:05:10 +02:00
|
|
|
if $uwsgi != undef and !defined(File[$uwsgi_params]) {
|
2014-06-24 18:17:08 +02:00
|
|
|
file { $uwsgi_params:
|
|
|
|
ensure => present,
|
|
|
|
mode => '0770',
|
2014-06-24 19:05:10 +02:00
|
|
|
content => template('nginx/vhost/uwsgi_params.erb'),
|
2014-06-24 18:17:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-04 13:54:48 +01:00
|
|
|
if (($listen_port + 0) != ($ssl_port + 0)) {
|
2013-12-24 18:22:32 +01:00
|
|
|
concat::fragment { "${name_sanitized}-header":
|
2013-12-01 01:51:31 +01:00
|
|
|
target => $config_file,
|
2013-11-22 05:23:45 +01:00
|
|
|
content => template('nginx/vhost/vhost_header.erb'),
|
2013-12-01 01:51:31 +01:00
|
|
|
order => '001',
|
2013-11-22 05:23:45 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-15 21:40:42 +02:00
|
|
|
# Create a proper file close stub.
|
2016-03-04 13:54:48 +01:00
|
|
|
if (($listen_port + 0) != ($ssl_port + 0)) {
|
2013-12-24 18:22:32 +01:00
|
|
|
concat::fragment { "${name_sanitized}-footer":
|
2013-12-01 01:51:31 +01:00
|
|
|
target => $config_file,
|
|
|
|
content => template('nginx/vhost/vhost_footer.erb'),
|
|
|
|
order => '699',
|
|
|
|
}
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Create SSL File Stubs if SSL is enabled
|
2013-05-26 14:24:40 +02:00
|
|
|
if ($ssl == true) {
|
2013-08-07 15:59:44 +02:00
|
|
|
# Access and error logs are named differently in ssl template
|
2014-06-10 00:49:33 +02:00
|
|
|
|
|
|
|
# This was a lot to add up in parameter list so add it down here
|
|
|
|
# Also opted to add more logic here and keep template cleaner which
|
|
|
|
# unfortunately means resorting to the $varname_real thing
|
2014-11-26 05:38:05 +01:00
|
|
|
$ssl_access_log_real = $access_log ? {
|
|
|
|
'off' => 'off',
|
2014-11-27 05:33:57 +01:00
|
|
|
undef => "${::nginx::config::log_dir}/ssl-${name_sanitized}.access.log ${format_log}",
|
2014-11-26 05:38:05 +01:00
|
|
|
default => "${access_log} ${format_log}",
|
2014-06-10 00:49:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
$ssl_error_log_real = $error_log ? {
|
2014-11-27 05:33:57 +01:00
|
|
|
undef => "${::nginx::config::log_dir}/ssl-${name_sanitized}.error.log",
|
2013-08-07 15:59:44 +02:00
|
|
|
default => $error_log,
|
|
|
|
}
|
2013-12-01 01:51:31 +01:00
|
|
|
|
2013-12-24 18:22:32 +01:00
|
|
|
concat::fragment { "${name_sanitized}-ssl-header":
|
2013-12-01 01:51:31 +01:00
|
|
|
target => $config_file,
|
2011-06-15 21:40:42 +02:00
|
|
|
content => template('nginx/vhost/vhost_ssl_header.erb'),
|
2013-12-01 01:51:31 +01:00
|
|
|
order => '700',
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
2013-12-24 18:22:32 +01:00
|
|
|
concat::fragment { "${name_sanitized}-ssl-footer":
|
2013-12-01 01:51:31 +01:00
|
|
|
target => $config_file,
|
2013-07-21 17:20:07 +02:00
|
|
|
content => template('nginx/vhost/vhost_ssl_footer.erb'),
|
2013-12-01 01:51:31 +01:00
|
|
|
order => '999',
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|
|
|
|
}
|
2013-12-01 01:51:31 +01:00
|
|
|
|
2013-12-24 18:22:32 +01:00
|
|
|
file{ "${name_sanitized}.conf symlink":
|
2013-12-01 01:51:31 +01:00
|
|
|
ensure => $vhost_symlink_ensure,
|
2013-12-24 18:22:32 +01:00
|
|
|
path => "${vhost_enable_dir}/${name_sanitized}.conf",
|
2013-12-01 01:51:31 +01:00
|
|
|
target => $config_file,
|
|
|
|
require => Concat[$config_file],
|
2015-01-24 23:04:18 +01:00
|
|
|
notify => Class['::nginx::service'],
|
2013-12-01 01:51:31 +01:00
|
|
|
}
|
2014-06-12 20:12:24 +02:00
|
|
|
|
2014-11-27 05:33:57 +01:00
|
|
|
create_resources('::nginx::resource::map', $string_mappings)
|
|
|
|
create_resources('::nginx::resource::geo', $geo_mappings)
|
2016-01-17 15:48:38 +01:00
|
|
|
create_resources('::nginx::resource::location', $locations, {
|
|
|
|
ensure => $ensure,
|
|
|
|
vhost => $name_sanitized,
|
|
|
|
ssl => $ssl,
|
|
|
|
ssl_only => $ssl_only,
|
|
|
|
www_root => $www_root,
|
|
|
|
})
|
2011-06-15 21:40:42 +02:00
|
|
|
}
|