2017-08-28 17:20:58 +02:00
|
|
|
# nginx:
|
2017-08-29 15:34:25 +02:00
|
|
|
install_from_source: True
|
|
|
|
use_upstart: True
|
|
|
|
use_sysvinit: False
|
|
|
|
user_auth_enabled: True
|
|
|
|
with_luajit: False
|
|
|
|
with_openresty: True
|
|
|
|
repo_version: development # Must be using ppa install by setting `repo_source = ppa`
|
|
|
|
set_real_ips: # NOTE: to use this, nginx must have http_realip module enabled
|
|
|
|
from_ips:
|
|
|
|
- 10.10.10.0/24
|
|
|
|
real_ip_header: X-Forwarded-For
|
|
|
|
modules:
|
|
|
|
headers-more:
|
|
|
|
source: http://github.com/agentzh/headers-more-nginx-module/tarball/v0.21
|
|
|
|
source_hash: sha1=dbf914cbf3f7b6cb7e033fa7b7c49e2f8879113b
|
2014-05-16 00:06:48 +02:00
|
|
|
|
|
|
|
# ========
|
|
|
|
# nginx.ng
|
|
|
|
# ========
|
|
|
|
|
|
|
|
nginx:
|
2014-05-19 19:04:43 +02:00
|
|
|
ng:
|
2017-06-24 15:43:25 +02:00
|
|
|
# The following three `install_from_` options are mutually exclusive. If none is used, the distro's provided
|
|
|
|
# package will be installed. If one of the `install_from` option is set to `True`, the state will
|
|
|
|
# make sure the other two repos are removed.
|
|
|
|
|
|
|
|
# Use the official's nginx repo binaries
|
|
|
|
install_from_repo: false
|
|
|
|
|
|
|
|
# Use Phusionpassenger's repo to install nginx and passenger binaries
|
|
|
|
# Debian, Centos, Ubuntu and Redhat are currently available
|
|
|
|
install_from_phusionpassenger: false
|
|
|
|
|
2016-05-09 17:31:29 +02:00
|
|
|
# PPA install
|
2017-06-24 15:43:25 +02:00
|
|
|
install_from_ppa: false
|
2015-02-23 22:16:41 +01:00
|
|
|
# Set to 'stable', 'development' (mainline), 'community', or 'nightly' for each build accordingly ( https://launchpad.net/~nginx )
|
2015-02-10 21:14:00 +01:00
|
|
|
ppa_version: 'stable'
|
2016-05-09 17:31:29 +02:00
|
|
|
|
|
|
|
# Source install
|
|
|
|
source_version: '1.10.0'
|
|
|
|
source_hash: ''
|
2017-12-12 21:10:51 +01:00
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
# These are usually set by grains in map.jinja
|
2017-08-29 15:34:25 +02:00
|
|
|
# Typically you can comment these out.
|
2014-05-19 19:04:43 +02:00
|
|
|
lookup:
|
2018-10-19 14:20:22 +02:00
|
|
|
package: nginx-custom (can be a list)
|
2017-08-29 15:34:25 +02:00
|
|
|
service: nginx
|
|
|
|
webuser: www-data
|
|
|
|
conf_file: /etc/nginx/nginx.conf
|
|
|
|
server_available: /etc/nginx/sites-available
|
|
|
|
server_enabled: /etc/nginx/sites-enabled
|
|
|
|
server_use_symlink: True
|
2018-02-14 01:27:15 +01:00
|
|
|
# If you install nginx+passenger from phusionpassenger in Debian, these values will probably be needed
|
|
|
|
passenger_package: libnginx-mod-http-passenger
|
|
|
|
passenger_config_file: /etc/nginx/conf.d/mod-http-passenger.conf
|
|
|
|
|
2015-05-17 17:23:01 +02:00
|
|
|
# This is required for RedHat like distros (Amazon Linux) that don't follow semantic versioning for $releasever
|
2017-08-29 15:34:25 +02:00
|
|
|
rh_os_releasever: '6'
|
2016-02-24 11:11:42 +01:00
|
|
|
# Currently it can be used on rhel/centos/suse when installing from repo
|
2017-08-29 15:34:25 +02:00
|
|
|
gpg_check: True
|
2017-08-28 17:20:58 +02:00
|
|
|
pid_file: /var/run/nginx.pid ### Prevent Rendering SLS error (map.jinja:149) if nginx.server.config.pid undefined (Ubuntu, etc) ###
|
2017-12-12 21:10:51 +01:00
|
|
|
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
# Source compilation is not currently a part of nginx.ng
|
2014-08-12 04:47:02 +02:00
|
|
|
from_source: False
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2016-05-09 17:31:29 +02:00
|
|
|
source:
|
|
|
|
opts: {}
|
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
package:
|
|
|
|
opts: {} # this partially exposes parameters of pkg.installed
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
service:
|
|
|
|
enable: True # Whether or not the service will be enabled/running or dead
|
|
|
|
opts: {} # this partially exposes parameters of service.running / service.dead
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2018-10-20 16:36:16 +02:00
|
|
|
snippets: # You can use snippets to define often repeated configuration once and include it later
|
|
|
|
letsencrypt: # e.g. this can be included using "- include: 'snippets/letsencrypt.conf'"
|
|
|
|
- location ^~ /.well-known/acme-challenge/:
|
|
|
|
- proxy_pass: http://localhost:9999
|
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
server:
|
|
|
|
opts: {} # this partially exposes file.managed parameters as they relate to the main nginx.conf file
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
# nginx.conf (main server) declarations
|
|
|
|
# dictionaries map to blocks {} and lists cause the same declaration to repeat with different values
|
2017-12-12 21:10:51 +01:00
|
|
|
config:
|
2017-08-31 13:19:46 +02:00
|
|
|
source_path: salt://path_to_nginx_conf_file/nginx.conf # IMPORTANT: This option is mutually exclusive with the rest of the
|
2017-12-12 21:10:51 +01:00
|
|
|
# options; if it is found other options (worker_processes: 4 and so
|
2017-08-30 19:48:44 +02:00
|
|
|
# on) are not processed and just upload the file from source
|
2014-05-19 19:04:43 +02:00
|
|
|
worker_processes: 4
|
2018-06-29 12:55:17 +02:00
|
|
|
load_module: modules/ngx_http_lua_module.so # this will be passed very first in configuration; otherwise nginx will fail to start
|
2018-09-23 23:11:40 +02:00
|
|
|
pid: /var/run/nginx.pid # Directory location must exist
|
2014-05-19 19:04:43 +02:00
|
|
|
events:
|
|
|
|
worker_connections: 768
|
|
|
|
http:
|
2014-07-05 05:34:48 +02:00
|
|
|
sendfile: 'on'
|
2014-05-19 19:04:43 +02:00
|
|
|
include:
|
2017-08-28 17:20:58 +02:00
|
|
|
#### Note: Syntax issues in these files generate nginx [emerg] errors on startup. ####
|
2014-05-19 19:04:43 +02:00
|
|
|
- /etc/nginx/mime.types
|
|
|
|
- /etc/nginx/conf.d/*.conf
|
2015-10-06 12:18:48 +02:00
|
|
|
- /etc/nginx/sites-enabled/*
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2016-10-19 23:35:38 +02:00
|
|
|
servers:
|
2014-05-19 19:04:43 +02:00
|
|
|
disabled_postfix: .disabled # a postfix appended to files when doing non-symlink disabling
|
|
|
|
symlink_opts: {} # partially exposes file.symlink params when symlinking enabled sites
|
|
|
|
rename_opts: {} # partially exposes file.rename params when not symlinking disabled/enabled sites
|
2016-10-19 23:35:38 +02:00
|
|
|
managed_opts: {} # partially exposes file.managed params for managed server files
|
2017-08-30 00:26:31 +02:00
|
|
|
dir_opts: {} # partially exposes file.directory params for site available/enabled and snippets dirs
|
2014-05-16 00:06:48 +02:00
|
|
|
|
2016-10-19 23:35:38 +02:00
|
|
|
# server declarations
|
|
|
|
# servers will default to being placed in server_available
|
2014-05-19 19:04:43 +02:00
|
|
|
managed:
|
2016-10-19 23:35:38 +02:00
|
|
|
mysite: # relative pathname of the server file
|
2014-05-19 19:04:43 +02:00
|
|
|
# may be True, False, or None where True is enabled, False, disabled, and None indicates no action
|
|
|
|
enabled: True
|
2017-09-01 11:23:15 +02:00
|
|
|
# Remove the site config file. Nice to clean up the conf.d (or sites-available).
|
|
|
|
# It also remove the symlink (if it is exists).
|
|
|
|
# The site MUST be disabled before delete it (if not the nginx is not reloaded).
|
2017-12-12 21:10:51 +01:00
|
|
|
deleted: True
|
|
|
|
###########
|
2017-08-29 15:34:25 +02:00
|
|
|
## Modify 'available_dir' AND 'enabled_dir' '/etc/nginx' location to alternative value.
|
2017-08-28 17:20:58 +02:00
|
|
|
###########
|
|
|
|
available_dir: /etc/nginx/sites-available # an alternate directory (not sites-available) where this server may be found
|
|
|
|
enabled_dir: /etc/nginx/sites-enabled # an alternate directory (not sites-enabled) where this server may be found
|
|
|
|
disabled_name: mysite.aint_on # an alternative disabled name to be use when not symlinking
|
2016-10-19 23:35:38 +02:00
|
|
|
overwrite: True # overwrite an existing server file or not
|
2017-12-12 21:10:51 +01:00
|
|
|
|
2016-10-19 23:35:38 +02:00
|
|
|
# May be a list of config options or None, if None, no server file will be managed/templated
|
2014-05-19 19:04:43 +02:00
|
|
|
# Take server directives as lists of dictionaries. If the dictionary value is another list of
|
|
|
|
# dictionaries a block {} will be started with the dictionary key name
|
|
|
|
config:
|
|
|
|
- server:
|
|
|
|
- server_name: localhost
|
2017-12-12 21:10:51 +01:00
|
|
|
- listen:
|
2014-05-19 19:04:43 +02:00
|
|
|
- 80
|
|
|
|
- default_server
|
|
|
|
- index:
|
|
|
|
- index.html
|
|
|
|
- index.htm
|
|
|
|
- location ~ .htm:
|
|
|
|
- try_files:
|
|
|
|
- $uri
|
|
|
|
- $uri/ =404
|
|
|
|
- test: something else
|
2018-10-20 16:36:16 +02:00
|
|
|
- include 'snippets/letsencrypt.conf'
|
2017-12-12 21:10:51 +01:00
|
|
|
|
2014-05-19 19:04:43 +02:00
|
|
|
# The above outputs:
|
|
|
|
# server {
|
|
|
|
# server_name localhost;
|
|
|
|
# listen 80 default_server;
|
|
|
|
# index index.html index.htm;
|
|
|
|
# location ~ .htm {
|
|
|
|
# try_files $uri $uri/ =404;
|
|
|
|
# test something else;
|
|
|
|
# }
|
2017-12-12 21:10:51 +01:00
|
|
|
# }
|
2017-08-31 13:19:46 +02:00
|
|
|
mysite2: # Using source_path options to upload the file instead of templating all the file
|
2017-08-30 19:48:44 +02:00
|
|
|
enabled: True
|
|
|
|
available_dir: /etc/nginx/sites-available
|
|
|
|
enabled_dir: /etc/nginx/sites-enabled
|
|
|
|
config:
|
2017-08-31 13:19:46 +02:00
|
|
|
source_path: salt://path-to-site-file/mysite2
|
2015-06-23 21:17:52 +02:00
|
|
|
|
2017-12-21 20:48:00 +01:00
|
|
|
# Below configuration becomes handy if you want to create custom configuration files
|
|
|
|
# for example if you want to create /usr/local/etc/nginx/http_options.conf with
|
|
|
|
# the following content:
|
|
|
|
|
|
|
|
# sendfile on;
|
|
|
|
# tcp_nopush on;
|
|
|
|
# tcp_nodelay on;
|
|
|
|
# send_iowait 12000;
|
|
|
|
|
|
|
|
http_options.conf:
|
|
|
|
enabled: True
|
|
|
|
available_dir: /usr/local/etc/nginx
|
|
|
|
enabled_dir: /usr/local/etc/nginx
|
|
|
|
config:
|
|
|
|
- sendfile: 'on'
|
|
|
|
- tcp_nopush: 'on'
|
|
|
|
- tcp_nodelay: 'on'
|
|
|
|
- send_iowait: 12000
|
|
|
|
|
2017-07-31 20:51:58 +02:00
|
|
|
certificates_path: '/etc/nginx/ssl' # Use this if you need to deploy below certificates in a custom path.
|
2015-06-23 21:17:52 +02:00
|
|
|
# If you're doing SSL termination, you can deploy certificates this way.
|
|
|
|
# The private one(s) should go in a separate pillar file not in version
|
|
|
|
# control (or use encrypted pillar data).
|
|
|
|
certificates:
|
|
|
|
'www.example.com':
|
|
|
|
public_cert: |
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
(Your Primary SSL certificate: www.example.com.crt)
|
|
|
|
-----END CERTIFICATE-----
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
(Your Intermediate certificate: ExampleCA.crt)
|
|
|
|
-----END CERTIFICATE-----
|
|
|
|
-----BEGIN CERTIFICATE-----
|
|
|
|
(Your Root certificate: TrustedRoot.crt)
|
|
|
|
-----END CERTIFICATE-----
|
|
|
|
private_key: |
|
|
|
|
-----BEGIN RSA PRIVATE KEY-----
|
|
|
|
(Your Private Key: www.example.com.key)
|
|
|
|
-----END RSA PRIVATE KEY-----
|
2017-06-24 15:43:25 +02:00
|
|
|
|
2017-07-11 12:19:47 +02:00
|
|
|
dh_param:
|
|
|
|
'mydhparam1.pem': |
|
|
|
|
-----BEGIN DH PARAMETERS-----
|
|
|
|
(Your custom DH prime)
|
|
|
|
-----END DH PARAMETERS-----
|
|
|
|
# or to generate one on-the-fly
|
|
|
|
'mydhparam2.pem':
|
|
|
|
keysize: 2048
|
2017-05-04 18:34:22 +02:00
|
|
|
|
2017-06-24 15:43:25 +02:00
|
|
|
# Passenger configuration
|
|
|
|
# Default passenger configuration is provided, and will be deployed in
|
|
|
|
# /etc/nginx/conf.d/passenger.conf
|
|
|
|
passenger:
|
|
|
|
passenger_root: /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
|
|
|
|
passenger_ruby: /usr/bin/ruby
|
|
|
|
passenger_instance_registry_dir: /var/run/passenger-instreg
|