Forge Home

nginx

This module manages the NGINX webserver

10,774 downloads

10,431 latest version

2.7 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

Version information

  • 0.0.2 (latest)
  • 0.0.1
released Sep 17th 2012

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'dhutty-nginx', '0.0.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add dhutty-nginx
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install dhutty-nginx --version 0.0.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download

Documentation

dhutty/nginx — version 0.0.2 Sep 17th 2012

dhutty-nginx

This is a puppet module to manage configuration of the NGINX webserver.

It's based very heavily on the work of James Fryman and Puppetlabs and their contributors. However, there are some significant differences in the implementation.

Example Usage

class {'nginx':
  nx_worker_processes => 2,
  nx_worker_connections => 2048,
  nx_client_max_body_size => '20m',
}
nginx::resource::vhost { 'test.example.com':
  ensure => present,
  server_names => ['test.example.com','foo.example.com'],
  listen_port => 443,
  www_root => '/var/www/nginx-default',
  ssl => true,
  ssl_cert => '/tmp/server.crt',
  ssl_key => '/tmp/server.pem',
}
nginx::resource::location { 'foo-ws':
  ensure => present,
  vhost => 'foo.example.com',
  location => '/ws',
  match_type => '~',
  proxy => 'http://app1',
  proxy_set_headers => {
  'REMOTE_ADDR' => '$remote_addr',
  'HTTP_HOST' => '$http_host',
  },
}
nginx::resource::upstream { 'app1':
  ensure => present,
  members => [
  'localhost:3000 weight=1',
  'unix:/var/run/appserver.sock weight=10',
  'otherserver.example.com:8080 backup',
  ],
}

Notes

I have attempted to make it easier to override module defaults, by using this kind of pattern:

$nx_worker_processes_real = $nx_worker_processes ? {
  'UNSET' => $::nginx::params::nx_worker_processes,
  default => $nx_worker_processes,
}

which allows this kind of syntax to override:

class {'nginx':
  nx_worker_processes => 2,
  nx_worker_connections => 2048,
  nx_client_max_body_size => '20m',
}
  • The implementation of ssl configurations is differen; SSL is only done at the server {...} context level, locations do not (need to) know whether they are ssl or not.
  • The force_ssl flag can be used to include a directive that rewrites all requests to the equivalent request but with the https scheme.
  • There is more flexibility with proxy settings, these are now easier to override on a per server/location basis.
  • I think I have defeated a bug where changing the manifest would not necessarily result in an update to the nginx config.
  • A little more accurate chaining of resources such that the service is refreshed if and only if its config has changed.
  • More closely following the style guide