This cookbook is a wrapper cookbook for the nginx opscode community cookbook. It primarily features a definition to manage vhosts using our standard configuration. It also ensure a few other settings are used by OSL default.
node['osl-nginx']['recipes']
- nginx recipes to include in run listnode['osl-nginx']['hostname']
- Default tonode['fqdn']
. Determines which folder under files/default to look for. If more than one server need access to a vhost.node['osl-nginx']['server_port']
- Default server port for nginx. Defaults to80
.node['osl-nginx']['directory_index']
- An array of the supported index files. Defaults to[ "index.html", "index.htm", "index.php" ]
Except for the 'default' recipe, all other recipes are OSL specific.
Includes the nginx recipes defined in node['osl-nginx']['recipes']
.
Project specific virtual hosts will be managed within these recipes.
Set logrotation for nginx log files.
Installs nginx with the default recipe. You can define which nginx recipes to
include with the node['osl-nginx']['recipes']
attribute. e.g. Adding more
nginx recipes in a run list:
{
"name":"my_node",
"run_list": [
"recipe[osl-nginx]"
]
override_attributes {
"osl-nginx" => {
"recipes" => ["default", "http_realip_module"]
}
}
}
This wrapper cookbook provides definitions for managing virtual hosts.
nginx_app
is similar to apache2's web_app
. It includes an OSL specific
template and creates log directories, and can manage ssl options for virtual
hosts.
This definition includes some recipes to make sure the system is configured to have nginx and some sane default modules:
osl-nginx::default
It will then configure the template and enable or disable the site per the
enable
parameter.
Current parameters used by the definition:
name
- The name of the site. Also defines theserver_name
variable in the vhost. the template will be written to#{node['nginx']['dir']/sites-available/#{params['name']}.conf
cookbook
- Name of the cookbook to pull the nginx template from. Defaults toosl-nginx
.template
- Defaultnginx_app.conf.erb
, source template file.enable
- Default true. Passed to thenginx_site
definition.cookbook_include
- Name of the cookbook to pull the optional include file from. Defaults to pulling from the cookbook being called from.include_name
- Boolean (optional). Adds theinclude
directive to the vhost config file. Defaults tofalse
.include_name
- Name of the include file (sans .conf). Defaults toname
.include_resource
- Type of chef resource to use include file from. Currently only supportscookbook_file
ortemplate
. Defaults tocookbook_file
.server_aliases
- Additional server names to be included. Must be an array of aliases.directory
- Creates the Defaults to/var/www/#{params['name']}
.ssl_enable
- Enables ssl support. Note thatssl_enable
,cert_file
, andcert_key
must be defined in order to populate the directive.cert_file
- Path to ssl cert.cert_key
- Path to ssl key.directive_http
- An array of nginx config directives to include only in the http vhost.directive_https
- An array of nginx config directives to include only in the https vhost.
Basic site
nginx_app "www.example.com" do
server_aliases ["www.example.org", "test.example.com"]
end
Basic site with an ssl cert and redirecting all http traffic to https.
nginx_app "www.example.org" do
server_aliases [ "www1.example.org", "www2.example.org" ]
directory "/var/www/www.example.org"
ssl_enable true
cert_file "/etc/pki/tls/certs/www.example.org.pem"
cert_key "/etc/pki/tls/private/www.example.org.key"
directive_http [ "rewrite ^ https://$server_name$request_uri? permanent;" ]
end
Basic site, but pull an include config from
files/default/example.org/www.example.org.conf
. This assumes the
node['osl-nginx']['hostname']
attribute is set to example.org
.
nginx_app "www.example.org" do
directory "/var/www/www.example.org"
include_config true
end
Basic site, but lets use an include config with a specific name and using a
template for it. This will use the template
templates/default/example.conf.erb
and use an include
directive.
nginx_app "www.example.org" do
directory "/var/www/www.example.org"
include_config true
include_resource "template"
include_name "example"
end
TODO: (optional) If this is a public cookbook, detail the process for contributing. If this is a private cookbook, remove this section.
e.g.
- Fork the repository on Github
- Create a named feature branch (like
add_component_x
) - Write you change
- Write tests for your change (if applicable)
- Run the tests, ensuring they all pass
- Submit a Pull Request using Github
Authors: OSU Open Source Lab ([email protected])