Creating Nginx virtual hosts
Nginx is a fast, lightweight web server that is preferred over Apache in many contexts, especially where high performance is important. The specifics of managing virtual hosts with Nginx are a little different, but the principles are the same.
How to do it…
In this recipe we'll see how to use Puppet to create and enable Nginx virtual hosts.
Run the following commands:
ubuntu@cookbook:~/puppet$ mkdir -p modules/nginx/manifests ubuntu@cookbook:~/puppet$ mkdir -p modules/nginx/templates
Create the file
modules/nginx/manifests/init.pp
with the following contents:# Manage Nginx class nginx { package { 'nginx': ensure => installed } service { 'nginx': ensure => running, enable => true, } exec { 'reload nginx': command => '/usr/sbin/service nginx reload', require => Package['nginx'], refreshonly => true, } }
Create the file
modules/nginx/manifests/vhost.pp
with the following contents:# Manage an Nginx virtual host...