Forge Home


This module manages the NGINX webserver


9,950 latest version

2.7 quality score

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.



dhutty/nginx — version 0.0.2 Sep 17th 2012


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 { '':
  ensure => present,
  server_names => ['',''],
  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 => '',
  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',
  ' backup',


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