Puppet Module to manage NGINX on various UNIXes
Puppet Module to manage NGINX on various UNIXes
This module was migrated from James Fryman to Vox Pupuli.
This module manages NGINX configuration.
include nginxnginx::resource::server { 'kibana.myhost.com':
listen_port => 80,
proxy => 'http://localhost:5601',
}nginx::resource::server { 'voxpupuli.org':
www_root => '/var/www/voxpupuli.org',
}nginx::resource::upstream { 'openvox_rack_app':
members => {
'localhost:3000' => {
server => 'localhost',
port => 3000,
weight => 1,
},
'localhost:3001' => {
server => 'localhost',
port => 3001,
weight => 1,
},
'localhost:3002' => {
server => 'localhost',
port => 3002,
weight => 2,
},
},
}
nginx::resource::server { 'rack.voxpupuli.org':
proxy => 'http://openvox_rack_app',
}class { 'nginx':
mail => true,
}
nginx::resource::mailhost { 'domain1.example':
auth_http => 'server2.example/cgi-bin/auth',
protocol => 'smtp',
listen_port => 587,
ssl_port => 465,
starttls => 'only',
xclient => 'off',
proxy_protocol => 'off',
proxy_smtp_auth => 'off',
ssl => true,
ssl_cert => '/tmp/server.crt',
ssl_key => '/tmp/server.pem',
}The datatype Array for members of a nginx::resource::upstream is replaced by a Hash. The following configuration is no longer valid:
nginx::resource::upstream { 'puppet_rack_app':
members => {
'localhost:3000',
'localhost:3001',
'localhost:3002',
},
}From now on, the configuration must look like this:
nginx::resource::upstream { 'puppet_rack_app':
members => {
'localhost:3000' => {
server => 'localhost',
port => 3000,
},
'localhost:3001' => {
server => 'localhost',
port => 3001,
},
'localhost:3002' => {
server => 'localhost',
port => 3002,
},
},
}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 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.
By default, this module might configure the deprecated ssl on directive. When
you next run puppet, this will be removed since the nginx_version fact will now
be available. To avoid this idempotency issue, you can manually set the base
class's nginx_version parameter.
Locations require specific settings depending on whether they should be included in the HTTP, HTTPS or both servers.
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.
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:
ssl => false on the location
(this is the default).ssl => true on the
location, and ensure ssl_only => false (which is the default value for ssl_only).ssl => true
and ssl_only => true on the location.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.
Defining nginx resources in Hiera.
……Example configuration for Debian and RHEL / CentOS (>6), pulling the Nginx and Passenger packages from the Phusion repo. See additional notes in https://github.com/voxpupuli/puppet-nginx/blob/master/docs/quickstart.md
class { 'nginx':
package_source => 'passenger',
http_cfg_append => {
'passenger_root' => '/usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini',
}
}Here the example for OpenBSD:
class { 'nginx':
package_flavor => 'passenger',
service_flags => '-u'
http_cfg_append => {
passenger_root => '/usr/local/lib/ruby/gems/2.1/gems/passenger-4.0.44',
passenger_ruby => '/usr/local/bin/ruby21',
passenger_max_pool_size => '15',
}
}Package source passenger will add Phusion Passenger repository
to APT sources. For each virtual host you should specify which ruby should be used.
nginx::resource::server { 'voxpupuli.org':
www_root => '/var/www/voxpupuli.org',
server_cfg_append => {
'passenger_enabled' => 'on',
'passenger_ruby' => '/usr/bin/ruby',
}
}Virtual host config for serving puppet master:
……nginx::resource::location { "some_root":
ensure => present,
location => '/some/url',
fastcgi => "127.0.0.1:9000",
fastcgi_param => {
'APP_ENV' => 'local',
},
}web::nginx_ssl_with_redirect { 'sub-domain-name':
backend_port => 9001,
}No open issues yet, or sync has not completed.