Skip to content

Commit

Permalink
Rename v[hH]ost to server everywhere
Browse files Browse the repository at this point in the history
Lint fixes.

Formatting

Replace stale code and re-format
  • Loading branch information
sacres committed Dec 1, 2016
1 parent 621778d commit 4b8c57f
Show file tree
Hide file tree
Showing 38 changed files with 375 additions and 375 deletions.
62 changes: 31 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class { 'nginx': }
### A simple reverse proxy

```puppet
nginx::resource::vhost { 'kibana.myhost.com':
nginx::resource::server { 'kibana.myhost.com':
listen_port => 80,
proxy => 'http://localhost:5601',
}
Expand All @@ -46,7 +46,7 @@ nginx::resource::vhost { 'kibana.myhost.com':
### A virtual host with static content

```puppet
nginx::resource::vhost { 'www.puppetlabs.com':
nginx::resource::server { 'www.puppetlabs.com':
www_root => '/var/www/www.puppetlabs.com',
}
```
Expand All @@ -62,7 +62,7 @@ nginx::resource::upstream { 'puppet_rack_app':
],
}
nginx::resource::vhost { 'rack.puppetlabs.com':
nginx::resource::server { 'rack.puppetlabs.com':
proxy => 'http://puppet_rack_app',
}
```
Expand All @@ -89,31 +89,31 @@ nginx::resource::mailhost { 'domain1.example':

## SSL configuration

By default, creating a vhost resource will only create a HTTP vhost. To also
create a HTTPS (SSL-enabled) vhost, set `ssl => true` on the vhost. You will
By default, creating a server resource will only create a HTTP server. To also
create a HTTPS (SSL-enabled) server, set `ssl => true` on the server. You will
have a HTTP server listening on `listen_port` (port `80` by default) and a HTTPS
server listening on `ssl_port` (port `443` by default). Both vhosts will have
server listening on `ssl_port` (port `443` by default). Both servers will have
the same `server_name` and a similar configuration.

To create only a HTTPS vhost, set `ssl => true` and also set `listen_port` to the
same value as `ssl_port`. Setting these to the same value disables the HTTP vhost.
The resulting vhost will be listening on `ssl_port`.
To create only a HTTPS server, set `ssl => true` and also set `listen_port` to the
same value as `ssl_port`. Setting these to the same value disables the HTTP server.
The resulting server will be listening on `ssl_port`.

### Locations

Locations require specific settings depending on whether they should be included
in the HTTP, HTTPS or both vhosts.
in the HTTP, HTTPS or both servers.

#### HTTP only vhost (default)
#### HTTP only server (default)

If you only have a HTTP vhost (i.e. `ssl => false` on the vhost) make sure you
don't set `ssl => true` on any location you associate with the vhost.
If you only have a HTTP server (i.e. `ssl => false` on the server) make sure you
don't set `ssl => true` on any location you associate with the server.

#### HTTP and HTTPS vhost
#### HTTP and HTTPS server

If you set `ssl => true` and also set `listen_port` and `ssl_port` to different
values on the vhost you will need to be specific with the location settings since
you will have a HTTP vhost listening on `listen_port` and a HTTPS vhost listening
values on the server you will need to be specific with the location settings since
you will have a HTTP server listening on `listen_port` and a HTTPS server listening
on `ssl_port`:

* To add a location to only the HTTP server, set `ssl => false` on the location
Expand All @@ -123,11 +123,11 @@ on `ssl_port`:
* To add a location only to the HTTPS server, set both `ssl => true`
and `ssl_only => true` on the location.

#### HTTPS only vhost
#### HTTPS only server

If you have set `ssl => true` and also set `listen_port` and `ssl_port` to the
same value on the vhost, you will have a single HTTPS vhost listening on
`ssl_port`. To add a location to this vhost set `ssl => true` and
same value on the server, you will have a single HTTPS server listening on
`ssl_port`. To add a location to this server set `ssl => true` and
`ssl_only => true` on the location.

## Hiera Support
Expand All @@ -142,19 +142,19 @@ nginx::nginx_upstreams:
- localhost:3000
- localhost:3001
- localhost:3002
nginx::nginx_vhosts:
nginx::nginx_servers:
'www.puppetlabs.com':
www_root: '/var/www/www.puppetlabs.com'
'rack.puppetlabs.com':
proxy: 'http://puppet_rack_app'
nginx::nginx_locations:
'static':
location: '~ "^/static/[0-9a-fA-F]{8}\/(.*)$"'
vhost: www.puppetlabs.com
server: www.puppetlabs.com
www_root: /var/www/html
'userContent':
location: /userContent
vhost: www.puppetlabs.com
server: www.puppetlabs.com
www_root: /var/www/html
nginx::nginx_mailhosts:
'smtp':
Expand Down Expand Up @@ -198,9 +198,9 @@ Package source `passenger` will add [Phusion Passenger repository](https://oss-b
to APT sources. For each virtual host you should specify which ruby should be used.

```puppet
nginx::resource::vhost { 'www.puppetlabs.com':
www_root => '/var/www/www.puppetlabs.com',
vhost_cfg_append => {
nginx::resource::server { 'www.puppetlabs.com':
www_root => '/var/www/www.puppetlabs.com',
server_cfg_append => {
'passenger_enabled' => 'on',
'passenger_ruby' => '/usr/bin/ruby',
}
Expand All @@ -212,15 +212,15 @@ nginx::resource::vhost { 'www.puppetlabs.com':
Virtual host config for serving puppet master:

```puppet
nginx::resource::vhost { 'puppet':
nginx::resource::server { 'puppet':
ensure => present,
server_name => ['puppet'],
listen_port => 8140,
ssl => true,
ssl_cert => '/var/lib/puppet/ssl/certs/example.com.pem',
ssl_key => '/var/lib/puppet/ssl/private_keys/example.com.pem',
ssl_port => 8140,
vhost_cfg_append => {
server_cfg_append => {
'passenger_enabled' => 'on',
'passenger_ruby' => '/usr/bin/ruby',
'ssl_crl' => '/var/lib/puppet/ssl/ca/ca_crl.pem',
Expand All @@ -239,7 +239,7 @@ nginx::resource::vhost { 'puppet':
}
```

### Example puppet class calling nginx::vhost with HTTPS FastCGI and redirection of HTTP
### Example puppet class calling nginx::server with HTTPS FastCGI and redirection of HTTP

```puppet
Expand All @@ -252,7 +252,7 @@ define web::nginx_ssl_with_redirect (
$www_root = "${full_web_path}/${name}/",
$location_cfg_append = undef,
) {
nginx::resource::vhost { "${name}.${::domain}":
nginx::resource::server { "${name}.${::domain}":
ensure => present,
www_root => "${full_web_path}/${name}/",
location_cfg_append => { 'rewrite' => '^ https://$server_name$request_uri? permanent' },
Expand All @@ -264,7 +264,7 @@ define web::nginx_ssl_with_redirect (
$tmp_www_root = $www_root
}
nginx::resource::vhost { "${name}.${::domain} ${name}":
nginx::resource::server { "${name}.${::domain} ${name}":
ensure => present,
listen_port => 443,
www_root => $tmp_www_root,
Expand All @@ -282,7 +282,7 @@ define web::nginx_ssl_with_redirect (
ensure => present,
ssl => true,
ssl_only => true,
vhost => "${name}.${::domain} ${name}",
server => "${name}.${::domain} ${name}",
www_root => "${full_web_path}/${name}/",
location => '~ \.php$',
index_files => ['index.php', 'index.html', 'index.htm'],
Expand Down
10 changes: 5 additions & 5 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The choices here are `nginx-stable` (the current 'production' level release), `n
Calling the `nginx` class from your manifest simply installs the NGINX software and puts some basic configuration in place. In this state, NGINX will not serve web pages or proxy to other services - for that, we need to define a *server*. In NGINX terminology, a *server* is how we define our services (such as websites) with a name. (If you are used to configuring Apache, a server is identical to an Apache *virtual host*.) A simple virtual host that serves static web pages can be defined with a server name and a *web root*, or the directory where our HTML pages are located.

```
nginx::resource::vhost{'www.myhost.com':
nginx::resource::server{'www.myhost.com':
www_root => '/opt/html/',
}
```
Expand All @@ -35,7 +35,7 @@ Setting up a simple static webserver is straightforward, but is usually not the
```
nginx::resource::location{'/blog':
proxy => 'http://192.168.99.1/' ,
vhost => 'www.myhost.com'
server => 'www.myhost.com'
}
```
This will proxy any requests made to `http://www.myhost.com/blog` to the URL `http://192.168.99.1/`. Pay special attention to the use of `/` at the end of the URL we are proxying to - that will allow your query parameters or subfolder structure on your secondary webserver to remain intact.
Expand All @@ -56,7 +56,7 @@ We can expand on these simple proxies by defining *upstream* resources for our w
```
nginx::resource::location{'/blog':
proxy => 'http://upstream_app/' ,
vhost => 'www.myhost.com'
server => 'www.myhost.com'
}
```
Now `/blog` will proxy requests to services defined in our `upstream_app` resource.
Expand All @@ -78,13 +78,13 @@ Combining our configurations above into a single manifest, our code block looks
],
}
nginx::resource::vhost{'www.myhost.com':
nginx::resource::server{'www.myhost.com':
www_root => '/opt/html/',
}
nginx::resource::location{'/proxy':
proxy => 'http://upstream_app/' ,
vhost => 'www.myhost.com',
server => 'www.myhost.com',
}
```
Expand Down
2 changes: 1 addition & 1 deletion examples/location_alias.pp
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
ensure => present,
location => '/some/url',
location_alias => '/new/url/',
vhost => 'www.test.com',
server => 'www.test.com',
}
2 changes: 1 addition & 1 deletion examples/location_params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
::nginx::resource::location { 'www.test.com-params':
ensure => present,
location => '/some/url',
vhost => 'www.test.com',
server => 'www.test.com',
fastcgi_param => {
'APP_ENV' => 'production',
'APP_VERSION' => '0.1.10',
Expand Down
4 changes: 2 additions & 2 deletions examples/vhost.pp → examples/server.pp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
include ::nginx

::nginx::resource::vhost { 'test.local test':
::nginx::resource::server { 'test.local test':
ensure => present,
ipv6_enable => true,
proxy => 'http://proxypass',
}

::nginx::resource::vhost { 'test.local:8080':
::nginx::resource::server { 'test.local:8080':
ensure => present,
listen_port => 8080,
server_name => ['test.local test'],
Expand Down
8 changes: 4 additions & 4 deletions examples/vhost_ssl.pp → examples/server_ssl.pp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include ::nginx

::nginx::resource::vhost { 'test3.local test3':
::nginx::resource::server { 'test3.local test3':
ensure => present,
www_root => '/var/www/nginx-default',
ssl => true,
Expand All @@ -9,7 +9,7 @@
ssl_key => 'puppet:///modules/sslkey/whildcard_mydomain.key',
}

::nginx::resource::vhost { 'test2.local test2':
::nginx::resource::server { 'test2.local test2':
ensure => present,
www_root => '/var/www/nginx-default',
ssl => true,
Expand All @@ -21,12 +21,12 @@
ensure => present,
www_root => '/var/www/bob',
location => '/bob',
vhost => 'test2.local test2',
server => 'test2.local test2',
}

::nginx::resource::location { 'test3.local-bob':
ensure => present,
www_root => '/var/www/bob',
location => '/bob',
vhost => 'test3.local test3',
server => 'test3.local test3',
}
10 changes: 5 additions & 5 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
$sites_available_mode = $::nginx::sites_available_mode
$super_user = $::nginx::super_user
$temp_dir = $::nginx::temp_dir
$vhost_purge = $::nginx::vhost_purge
$server_purge = $::nginx::server_purge
$accept_mutex = $::nginx::accept_mutex
$accept_mutex_delay = $::nginx::accept_mutex_delay
$client_body_buffer_size = $::nginx::client_body_buffer_size
Expand Down Expand Up @@ -132,10 +132,10 @@
ensure => directory,
}
if $confd_purge {
# Err on the side of caution - make sure *both* $vhost_purge and
# Err on the side of caution - make sure *both* $server_purge and
# $confd_purge are set if $confd_only is set, before purging files
# ${conf_dir}/conf.d
if (($confd_only and $vhost_purge) or !$confd_only) {
if (($confd_only and $server_purge) or !$confd_only) {
File["${conf_dir}/conf.d"] {
purge => true,
recurse => true,
Expand Down Expand Up @@ -194,7 +194,7 @@
file { "${conf_dir}/sites-enabled":
ensure => directory,
}
if $vhost_purge {
if $server_purge {
File["${conf_dir}/sites-available"] {
purge => true,
recurse => true,
Expand All @@ -214,7 +214,7 @@
file { "${conf_dir}/streams-available":
ensure => directory,
}
if $vhost_purge {
if $server_purge {
File["${conf_dir}/streams-enabled"] {
purge => true,
recurse => true,
Expand Down
10 changes: 5 additions & 5 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
$sites_available_mode = $::nginx::params::sites_available_mode,
$super_user = $::nginx::params::super_user,
$temp_dir = $::nginx::params::temp_dir,
$vhost_purge = false,
$server_purge = false,

# Primary Templates
$conf_template = 'nginx/conf.d/nginx.conf.erb',
Expand Down Expand Up @@ -154,8 +154,8 @@
$nginx_mailhosts = {},
$nginx_streamhosts = {},
$nginx_upstreams = {},
$nginx_vhosts = {},
$nginx_vhosts_defaults = {},
$nginx_servers = {},
$nginx_servers_defaults = {},
### END Hiera Lookups ###
) inherits ::nginx::params {

Expand Down Expand Up @@ -184,7 +184,7 @@
}
validate_bool($confd_only)
validate_bool($confd_purge)
validate_bool($vhost_purge)
validate_bool($server_purge)
if ( $proxy_cache_path != false) {
if ( is_string($proxy_cache_path) or is_hash($proxy_cache_path)) {}
else {
Expand Down Expand Up @@ -272,7 +272,7 @@
Class['::nginx::package'] -> Class['::nginx::config'] ~> Class['::nginx::service']

create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::vhost', $nginx_vhosts, $nginx_vhosts_defaults)
create_resources('nginx::resource::server', $nginx_servers, $nginx_servers_defaults)
create_resources('nginx::resource::location', $nginx_locations)
create_resources('nginx::resource::mailhost', $nginx_mailhosts)
create_resources('nginx::resource::streamhost', $nginx_streamhosts)
Expand Down
Loading

1 comment on commit 4b8c57f

@kwisatz
Copy link

@kwisatz kwisatz commented on 4b8c57f Dec 5, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would've been nice to have a release 0.5.1 prior to merging this change. We're using the master branch since release 0.5.0 was missing some important functionality. I realize one shouldn't necessarily use a branch but rather tags, but I think this change would have merited tagging the revision prior to the merge.

Please sign in to comment.