Skip to content


Switch branches/tags
This branch is 4 commits ahead, 214 commits behind netmanagers:master.

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Puppet module: nginx

This is a Puppet nginx module from the second generation of Example42 Puppet Modules.

Made by Alessandro Franceschi / Lab42

The nginx::resource

classes and relevant code has been cloned from

which is a fort of James Fryman /PuppetLabs original nginx module

Official site:

Official git repository:

Released under the terms of Apache 2 License.

This module requires functions provided by the Example42 Puppi module.

For detailed info about the logic and usage patterns of Example42 modules read README.usage on Example42 main modules set.

USAGE - Basic management

  • Install nginx with default settings

    class { "nginx": }
  • Disable nginx service.

    class { "nginx":
      disable => true
  • Disable nginx service at boot time, but don't stop if is running.

    class { "nginx":
      disableboot => true
  • Remove nginx package

    class { "nginx":
      absent => true
  • Enable auditing without without making changes on existing nginx configuration files

    class { "nginx":
      audit_only => true

USAGE - Overrides and Customizations

  • Use custom sources for main config file

    class { "nginx":
      source => [ "puppet:///modules/lab42/nginx/nginx.conf-${hostname}" , "puppet:///modules/lab42/nginx/nginx.conf" ], 
  • Use custom source directory for the whole configuration dir

    class { "nginx":
      source_dir       => "puppet:///modules/lab42/nginx/conf/",
      source_dir_purge => false, # Set to true to purge any existing file not present in $source_dir
  • Use custom template for main config file

    class { "nginx":
      template => "example42/nginx/nginx.conf.erb",      
  • Define custom options that can be used in a custom template without the need to add parameters to the nginx class

    class { "nginx":
      template => "example42/nginx/nginx.conf.erb",    
      options  => {
        'LogLevel' => 'INFO',
        'UsePAM'   => 'yes',
  • Automaticallly include a custom subclass

    class { "nginx:"
      my_class => 'nginx::example42',

USAGE - Example42 extensions management

  • Activate puppi (recommended, but disabled by default) Note that this option requires the usage of Example42 puppi module

    class { "nginx": 
      puppi    => true,
  • Activate puppi and use a custom puppi_helper template (to be provided separately with a puppi::helper define ) to customize the output of puppi commands

    class { "nginx":
      puppi        => true,
      puppi_helper => "myhelper", 
  • Activate automatic monitoring (recommended, but disabled by default) This option requires the usage of Example42 monitor and relevant monitor tools modules

    class { "nginx":
      monitor      => true,
      monitor_tool => [ "nagios" , "monit" , "munin" ],
  • Activate automatic firewalling This option requires the usage of Example42 firewall and relevant firewall tools modules

    class { "nginx":       
      firewall      => true,
      firewall_tool => "iptables",
      firewall_src  => "",
      firewall_dst  => "$ipaddress_eth0",

USAGE - VirtualHost

You have 2 different options to manage virtual hosts

  • Use the nginx::vhost define, whose logic and parameters are similar to Example42 apache::vhost and where you have to set your docroot and eventually a custom template to use:

    nginx::vhost { '' :
      template => 'myproject/nginx/mydomain/nginx.conf.erb',
      docroot  => '/var/www/mydomain',
  • Use the nginx::resource::vhost define which has been ported from puppetlabs/nginx module and it provides more flexibility in the management of virtual hosts and single location statements (with the nginx::resource::location define).

    Note this the nginx::resource

    defines require


Puppet Nginx module






No releases published


No packages published


  • Puppet 74.4%
  • Ruby 25.6%