Skip to content

Commit

Permalink
Merge pull request #59 from abraham1901/master
Browse files Browse the repository at this point in the history
Fixed errors and implemented new functions
  • Loading branch information
James Fryman committed May 21, 2013
2 parents 349ae7d + a5ebd57 commit f032357
Show file tree
Hide file tree
Showing 13 changed files with 259 additions and 103 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2011-12-23 Sam Bashton <[email protected]>
* manifests/resource/location.pp,manifests/resource/vhost.pp,
templates/vhost/vhost_location_fastcgi.erb: Add support for fastcgi

2011-06-06 James Fryman <[email protected]>

* Modulefile, README, files/README.markdown, lib/facter/README.markdown,
Expand Down
28 changes: 16 additions & 12 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,18 @@
#
# This class file is not called directly
class nginx::config(
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$confd_purge = $nginx::params::nx_confd_purge,
$server_tokens = $nginx::params::nx_server_tokens,
$types_hash_max_size = $nginx::params::nx_types_hash_max_size,
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$confd_purge = $nginx::params::nx_confd_purge,
$server_tokens = $nginx::params::nx_server_tokens,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_cache_path = $nginx::params::nx_proxy_cache_path,
$proxy_cache_levels = $nginx::params::nx_proxy_cache_levels,
$proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone,
$proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size,
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$types_hash_max_size = $nginx::params::nx_types_hash_max_size,
$types_hash_bucket_size = $nginx::params::nx_types_hash_bucket_size
) inherits nginx::params {
File {
Expand All @@ -29,7 +34,7 @@
mode => '0644',
}

file { "${nginx::params::nx_conf_dir}":
file { $nginx::params::nx_conf_dir:
ensure => directory,
}

Expand All @@ -55,17 +60,16 @@
}
}


file { "${nginx::config::nx_run_dir}":
file {$nginx::config::nx_run_dir:
ensure => directory,
}

file { "${nginx::config::nx_client_body_temp_path}":
file {$nginx::config::nx_client_body_temp_path:
ensure => directory,
owner => $nginx::params::nx_daemon_user,
}

file {"${nginx::config::nx_proxy_temp_path}":
file {$nginx::config::nx_proxy_temp_path:
ensure => directory,
owner => $nginx::params::nx_daemon_user,
}
Expand Down
47 changes: 28 additions & 19 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
# Parameters:
#
# There are no default parameters for this class. All module parameters are
# managed via the nginx::params class
# There are no default parameters for this class. All module parameters are managed
# via the nginx::params class
#
# Actions:
#
Expand All @@ -29,15 +29,20 @@
# include nginx
# }
class nginx (
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$confd_purge = $nginx::params::nx_confd_purge,
$configtest_enable = $nginx::params::nx_configtest_enable,
$service_restart = $nginx::params::nx_service_restart,
$mail = $nginx::params::nx_mail,
$server_tokens = $nginx::params::nx_server_tokens
$worker_processes = $nginx::params::nx_worker_processes,
$worker_connections = $nginx::params::nx_worker_connections,
$proxy_set_header = $nginx::params::nx_proxy_set_header,
$proxy_http_version = $nginx::params::nx_proxy_http_version,
$confd_purge = $nginx::params::nx_confd_purge,
$proxy_cache_path = $nginx::params::nx_proxy_cache_path,
$proxy_cache_levels = $nginx::params::nx_proxy_cache_levels,
$proxy_cache_keys_zone = $nginx::params::nx_proxy_cache_keys_zone,
$proxy_cache_max_size = $nginx::params::nx_proxy_cache_max_size,
$proxy_cache_inactive = $nginx::params::nx_proxy_cache_inactive,
$configtest_enable = $nginx::params::nx_configtest_enable,
$service_restart = $nginx::params::nx_service_restrart,
$mail = $nginx::params::nx_mail,
$server_tokens = $nginx::params::nx_server_tokens
) inherits nginx::params {

include stdlib
Expand All @@ -47,14 +52,18 @@
}

class { 'nginx::config':
worker_processes => $worker_processes,
worker_connections => $worker_connections,
proxy_set_header => $proxy_set_header,
proxy_http_version => $proxy_http_version,
confd_purge => $confd_purge,
server_tokens => $server_tokens,
require => Class['nginx::package'],
notify => Class['nginx::service'],
worker_processes => $worker_processes,
worker_connections => $worker_connections,
proxy_set_header => $proxy_set_header,
proxy_http_version => $proxy_http_version,
proxy_cache_path => $proxy_cache_path,
proxy_cache_levels => $proxy_cache_levels,
proxy_cache_keys_zone => $proxy_cache_keys_zone,
proxy_cache_max_size => $proxy_cache_max_size,
proxy_cache_inactive => $proxy_cache_inactive,
confd_purge => $confd_purge,
require => Class['nginx::package'],
notify => Class['nginx::service'],
}

class { 'nginx::service':
Expand Down
38 changes: 22 additions & 16 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,37 @@
#
# This class file is not called directly
class nginx::params {
$nx_temp_dir = '/tmp'
$nx_run_dir = '/var/nginx'
$nx_temp_dir = '/tmp'
$nx_run_dir = '/var/nginx'

$nx_conf_dir = '/etc/nginx'
$nx_confd_purge = false
$nx_worker_processes = 1
$nx_worker_connections = 1024
$nx_types_hash_max_size = 1024
$nx_types_hash_bucket_size = 512
$nx_multi_accept = off
$nx_conf_dir = '/etc/nginx'
$nx_confd_purge = false
$nx_worker_processes = 1
$nx_worker_connections = 1024
$nx_types_hash_max_size = 1024
$nx_types_hash_bucket_size = 512
$nx_multi_accept = off
$nx_events_use = false # One of [kqueue|rtsig|epoll|/dev/poll|select|poll|eventport] or false to use OS default
$nx_sendfile = on
$nx_keepalive_timeout = 65
$nx_tcp_nodelay = on
$nx_gzip = on
$nx_server_tokens = on
$nx_spdy = off
$nx_ssl_stapling = off
$nx_sendfile = on
$nx_keepalive_timeout = 65
$nx_tcp_nodelay = on
$nx_gzip = on
$nx_server_tokens = on
$nx_spdy = off
$nx_ssl_stapling = off


$nx_proxy_redirect = off
$nx_proxy_set_header = [
'Host $host',
'X-Real-IP $remote_addr',
'X-Forwarded-For $proxy_add_x_forwarded_for',
]
$nx_proxy_cache_path = false
$nx_proxy_cache_levels = 1
$nx_proxy_cache_keys_zone = 'd2:100m'
$nx_proxy_cache_max_size = '500m'
$nx_proxy_cache_inactive = '20m'

$nx_client_body_temp_path = "${nx_run_dir}/client_body_temp"
$nx_client_body_buffer_size = '128k'
Expand Down
52 changes: 40 additions & 12 deletions manifests/resource/location.pp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# [*proxy*] - Proxy server(s) for a 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
# [*fastcgi*] - location of fastcgi (host:port)
# [*fastcgi_params*] - optional alternative fastcgi_params file to use
# [*fastcgi_script*] - optional SCRIPT_FILE parameter
# [*ssl*] - Indicates whether to setup SSL bindings for this location.
# [*ssl_only*] - Required if the SSL and normal vHost have the same port.
# [*location_alias*] - Path to be used as basis for serving requests for this location
Expand All @@ -19,6 +22,14 @@
# [*location_cfg_append*] - It expects a hash with custom directives to put after everything else inside location
# [*try_files*] - An array of file locations to try
# [*option*] - Reserved for future use
# [*proxy_cache*] - This directive sets name of zone for caching.
# The same zone can be used in multiple places.
# [*proxy_cache_valid*] - This directive sets the time for caching
# different replies.
# [*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.
#
# Actions:
#
Expand Down Expand Up @@ -58,14 +69,21 @@
'index.php'],
$proxy = undef,
$proxy_read_timeout = $nginx::params::nx_proxy_read_timeout,
$fastcgi = undef,
$fastcgi_params = '/etc/nginx/fastcgi_params',
$fastcgi_script = undef,
$ssl = false,
$ssl_only = false,
$location_alias = undef,
$option = undef,
$stub_status = undef,
$location_cfg_prepend = undef,
$location_cfg_append = undef,
$try_files = undef
$try_files = undef,
$proxy_cache = false,
$proxy_cache_valid = false,
$auth_basic = undef,
$auth_basic_user_file = undef
) {
File {
owner => 'root',
Expand All @@ -80,43 +98,53 @@
default => file,
}

# Use proxy template if $proxy is defined, otherwise use directory template.
# Use proxy or fastcgi template if $proxy is defined, otherwise use directory template.
if ($proxy != undef) {
$content_real = template('nginx/vhost/vhost_location_proxy.erb')
} elsif ($location_alias != undef) {
$content_real = template('nginx/vhost/vhost_location_alias.erb')
} elsif ($stub_status != undef) {
$content_real = template('nginx/vhost/vhost_location_stub_status.erb')
} elsif ($fastcgi != undef) {
$content_real = template('nginx/vhost/vhost_location_fastcgi.erb')
} else {
$content_real = template('nginx/vhost/vhost_location_directory.erb')
}

# # Check for various error condtiions
## Check for various error conditions
if ($vhost == undef) {
fail('Cannot create a location reference without attaching to a virtual host')
}

if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef)) {
fail('Cannot create a location reference without a www_root, proxy, location_alias or stub_status defined')
if (($www_root == undef) and ($proxy == undef) and ($location_alias == undef) and ($stub_status == undef) and ($fastcgi == undef)) {
fail('Cannot create a location reference without a www_root, proxy, location_alias, fastcgi or stub_status defined')
}

if (($www_root != undef) and ($proxy != undef)) {
fail('Cannot define both directory and proxy in a virtual host')
}

# # Create stubs for vHost File Fragment Pattern
if (!$ssl_only) {
file { "${nginx::config::nx_temp_dir}/nginx.d/${vhost}-500-${name}":
## Create stubs for vHost File Fragment Pattern
if ($ssl_only != 'true') {
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-500-${name}":
ensure => $ensure_real,
content => $content_real,
}
}

# # Only create SSL Specific locations if $ssl is true.
if ($ssl) {
file { "${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl":
## Only create SSL Specific locations if $ssl is true.
if ($ssl == 'true') {
file {"${nginx::config::nx_temp_dir}/nginx.d/${vhost}-800-${name}-ssl":
ensure => $ensure_real,
content => $content_real,
}
}

if ($auth_basic_user_file != undef) {
#Generate htpasswd with provided file-locations
file { "${nginx::params::nx_conf_dir}/${name}_htpasswd":
ensure => $ensure,
mode => '0644',
source => $auth_basic_user_file,
}
}
}
Loading

0 comments on commit f032357

Please sign in to comment.