Saltstack Official Nginx Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

393 lines
15KB

  1. # -*- coding: utf-8 -*-
  2. # vim: ft=yaml
  3. ---
  4. # ========
  5. # nginx (previously named nginx:ng)
  6. # ========
  7. nginx:
  8. # The following three `install_from_` options are mutually exclusive. If none
  9. # is used, the distro's provided package will be installed. If one of the
  10. # `install_from` option is set to `true`, the state will make sure the other
  11. # two repos are removed.
  12. # Use the official's nginx repo binaries
  13. install_from_repo: false
  14. # Use Phusionpassenger's repo to install nginx and passenger binaries
  15. # Debian, Centos, Ubuntu and Redhat are currently available
  16. install_from_phusionpassenger: false
  17. # PPA install
  18. install_from_ppa: false
  19. # Set to 'stable', 'development' (mainline), 'community', or 'nightly' for
  20. # each build accordingly ( https://launchpad.net/~nginx )
  21. ppa_version: 'stable'
  22. # Use openSUSE devel (server:http) repository to install nginx.
  23. # If not set, the server_http repository will be removed if it exists.
  24. install_from_opensuse_devel: false
  25. # Source install
  26. source_version: '1.10.0'
  27. source_hash: ''
  28. # Check the configuration before applying:
  29. # To prevent applying a configuration that might break nginx, set this
  30. # parameter to true so the configuration is checked BEFORE applying. If
  31. # the check fails, the state will fail and it won't be deployed.
  32. # CAVEAT: As the configuration file is created in a temp dir, it can't
  33. # have relative references or it will fail to check. You'll need to
  34. # specify full paths where required (ie, `include`, `load_module`,
  35. # `snippets`, etc.0
  36. # Defaults to false
  37. check_config_before_apply: false
  38. # These are usually set by grains in map.jinja
  39. # Typically you can comment these out.
  40. lookup:
  41. package: nginx-custom (can be a list)
  42. service: nginx
  43. webuser: www-data
  44. conf_file: /etc/nginx/nginx.conf
  45. server_available: /etc/nginx/sites-available
  46. server_enabled: /etc/nginx/sites-enabled
  47. server_use_symlink: true
  48. # If you install nginx+passenger from phusionpassenger in Debian, these
  49. # values will probably be needed
  50. passenger_package: libnginx-mod-http-passenger
  51. passenger_config_file: /etc/nginx/conf.d/mod-http-passenger.conf
  52. # This is required for RedHat like distros (Amazon Linux) that don't follow
  53. # semantic versioning for $releasever
  54. rh_os_releasever: '6'
  55. # Currently it can be used on rhel/centos/suse when installing from repo
  56. gpg_check: true
  57. ### prevents rendering SLS error nginx.server.config.pid undefined ###
  58. pid_file: /var/run/nginx.pid
  59. # Source compilation is not currently a part of nginx
  60. from_source: false
  61. source:
  62. opts: {}
  63. package:
  64. opts: {} # this partially exposes parameters of pkg.installed
  65. service:
  66. enable: true # Whether or not the service will be enabled/running or dead
  67. opts: {} # this partially exposes parameters of service.running / service.dead
  68. ## - - -- - - -- -- - - --- -- - -- - - - -- - - - - -- - - - -- - - - -- - ##
  69. ## You can use snippets to define often repeated configuration once and
  70. ## include it later # The letsencrypt example below is consumed by "- include:
  71. ## 'snippets/letsencrypt.conf'" # Files or Templates can be retrieved by TOFS
  72. ## with snippet name ( Fallback to server.conf )
  73. ## - - -- - - -- -- - - --- -- - -- - - - -- - - - - -- - - - -- - - - -- - ##
  74. snippets:
  75. letsencrypt.conf:
  76. - location ^~ /.well-known/acme-challenge/:
  77. - proxy_pass: http://localhost:9999
  78. cloudflare_proxy.conf:
  79. - set_real_ip_from: 103.21.244.0/22
  80. - set_real_ip_from: 103.22.200.0/22
  81. - set_real_ip_from: 104.16.0.0/12
  82. - set_real_ip_from: 108.162.192.0/18
  83. blacklist.conf:
  84. - map $http_user_agent $bad_bot:
  85. - default: 0
  86. - '~*^Lynx': 0
  87. - '~*malicious': 1
  88. - '~*bot': 1
  89. - '~*crawler': 1
  90. - '~*bandit': 1
  91. - libwww-perl: 1
  92. - '~(?i)(httrack|htmlparser|libwww)': 1
  93. upstream_netdata_tcp.conf:
  94. - upstream netdata:
  95. - server: 127.0.0.1:19999
  96. - keepalive: 64
  97. server:
  98. # this partially exposes file.managed parameters as they relate to the main
  99. # nginx.conf file
  100. opts: {}
  101. ## - - -- - - -- -- - - --- -- - -- - - - -- - - - - -- - - - -- - - - -- - ##
  102. # nginx.conf (main server) declarations dictionaries map to blocks {} and
  103. # lists cause the same declaration to repeat with different values see also
  104. # http://nginx.org/en/docs/example.html Nginx config file or template can
  105. # be retrieved by TOFS ( Fallback to nginx.conf )
  106. ## - - -- - - -- -- - - --- -- - -- - - - -- - - - - -- - - - -- - - - -- - ##
  107. config:
  108. include: 'snippets/letsencrypt.conf'
  109. # IMPORTANT: This option is mutually exclusive with TOFS.
  110. # It uploads the file from source and passes the global `nginx` and the
  111. # `config` dictionnary to the template.
  112. # `jinja` is assumed as template type.
  113. source_path: salt://path_to_nginx_conf_file/nginx.conf
  114. worker_processes: 4
  115. # pass as very first in configuration; otherwise nginx will fail to start
  116. load_module: modules/ngx_http_lua_module.so
  117. # Directory location must exist (i.e. it's /run/nginx.pid on EL7)
  118. # pid: /var/run/nginx.pid
  119. events:
  120. worker_connections: 1024
  121. http:
  122. sendfile: 'on'
  123. include:
  124. #### Note: Syntax issues in these files generate nginx [emerg] errors
  125. #### on startup.
  126. - /etc/nginx/mime.types
  127. ### module ngx_http_log_module example
  128. log_format: |-
  129. main '$remote_addr - $remote_user [$time_local] $status '
  130. '"$request" $body_bytes_sent "$http_referer" '
  131. '"$http_user_agent" "$http_x_forwarded_for"'
  132. access_log: [] # suppress default access_log option from being added
  133. # module nngx_stream_core_module
  134. # yamllint disable-line rule:line-length
  135. # https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/#example
  136. stream:
  137. upstream lb-1000:
  138. - server:
  139. - hostname1.example.com:1000
  140. - hostname2.example.com:1000
  141. upstream stream_backend:
  142. least_conn: ''
  143. 'server backend1.example.com:12345 weight=5': ~
  144. 'server backend2.example.com:12345 max_fails=2 fail_timeout=30s': ~
  145. 'server backend3.example.com:12345 max_conns=3': ~
  146. upstream dns_servers:
  147. least_conn: ''
  148. 'server 192.168.136.130:53': ~
  149. 'server 192.168.136.131:53': ~
  150. 'server 192.168.136.132:53': ~
  151. server:
  152. listen: 1000
  153. proxy_pass: lb-1000
  154. 'server ':
  155. listen: '53 udp'
  156. proxy_pass: dns_servers
  157. 'server ':
  158. listen: 12346
  159. proxy_pass: backend4.example.com:12346
  160. servers:
  161. # a postfix appended to files when doing non-symlink disabling
  162. disabled_postfix: .disabled
  163. # partially exposes file.symlink params when symlinking enabled sites
  164. symlink_opts: {}
  165. # partially exposes file.rename params when not symlinking disabled/enabled sites
  166. rename_opts: {}
  167. # partially exposes file.managed params for managed server files
  168. managed_opts: {}
  169. # partially exposes file.directory params for site available/enabled and
  170. # snippets dirs
  171. dir_opts: {}
  172. # let the choice to purge site-available and site-enable folders before add new ones
  173. # (if True it removes all non-salt-managed files)
  174. purge_servers_config: false
  175. #####################
  176. # server declarations; placed by default in server "available" directory
  177. #####################
  178. managed:
  179. # relative filename of server file
  180. # (defaults to '/etc/nginx/sites-available/mysite')
  181. mysite:
  182. # may be true, false, or None where true is enabled, false, disabled,
  183. # and None indicates no action
  184. enabled: true
  185. # This let's you add dependencies on other resources being applied for a
  186. # particular vhost
  187. # A common case is when you use this formula together with letsencrypt's,
  188. # validating through nginx: you need nginx running (to validate the vhost) but
  189. # can't have the ssl vhost up until the certificate is created (because it
  190. # won't exist and will make nginx fail to load the configuration)
  191. #
  192. # An example, when using LE to create the cert for 'some.host.domain':
  193. # requires:
  194. # cmd: create-initial-cert-some.host.domain
  195. requires: {}
  196. # Remove the site config file shipped by nginx
  197. # (i.e. '/etc/nginx/sites-available/default' by default)
  198. # It also remove the symlink (if it is exists).
  199. # The site MUST be disabled before delete it (if not the nginx is not
  200. # reloaded).
  201. # deleted: true
  202. # custom directory (not sites-available) for server filename
  203. # available_dir: /etc/nginx/sites-available-custom
  204. # custom directory (not sites-enabled) for server filename
  205. # enabled_dir: /etc/nginx/sites-enabled-custom
  206. # an alternative disabled name to be use when not symlinking
  207. disabled_name: mysite.aint_on
  208. # overwrite an existing server file or not
  209. overwrite: true
  210. # May be a list of config options or None, if None, no server file will
  211. # be managed/templated Take server directives as lists of dictionaries.
  212. # If the dictionary value is another list of dictionaries a block {}
  213. # will be started with the dictionary key name
  214. config:
  215. # both of the methods below lead to the output:
  216. # server {
  217. # server_name localhost;
  218. # listen 80 default_server;
  219. # listen 443 ssl;
  220. # index index.html index.htm;
  221. # location ~ .htm {
  222. # try_files $uri $uri/ =404;
  223. # test something else;
  224. # }
  225. # }
  226. - server:
  227. - server_name: localhost
  228. - listen:
  229. - '80 default_server'
  230. - listen:
  231. - '443 ssl'
  232. - index: 'index.html index.htm'
  233. - location ~ .htm:
  234. - try_files: '$uri $uri/ =404'
  235. - test: something else
  236. - include: 'snippets/letsencrypt.conf'
  237. # Or a slightly more compact alternative syntax:
  238. - server:
  239. - server_name: localhost
  240. - listen:
  241. - '80 default_server'
  242. - '443 ssl'
  243. - index: 'index.html index.htm'
  244. - location ~ .htm:
  245. - try_files: '$uri $uri/ =404'
  246. - test: something else
  247. - include: 'snippets/letsencrypt.conf'
  248. # Using source_path options to upload the file instead of templating all the file
  249. mysite2:
  250. enabled: true
  251. available_dir: /etc/nginx/sites-available
  252. enabled_dir: /etc/nginx/sites-enabled
  253. config:
  254. # IMPORTANT: This field is mutually exclusive with TOFS.
  255. # It uploads the file from source and passes the global `nginx` and the
  256. # `config` dictionnary to the template.
  257. # `jinja` is assumed as template type.
  258. source_path: salt://path-to-site-file/mysite2
  259. # Example:
  260. port: 80 # is passed as `config.port` to template located at `source_path`
  261. custom_key: custom_value
  262. # Below configuration becomes handy if you want to create custom
  263. # configuration files for example if you want to create
  264. # /usr/local/etc/nginx/http_options.conf with the following content:
  265. # sendfile on;
  266. # tcp_nopush on;
  267. # tcp_nodelay on;
  268. # send_iowait 12000;
  269. http_options.conf:
  270. enabled: true
  271. available_dir: /usr/local/etc/nginx
  272. enabled_dir: /usr/local/etc/nginx
  273. config:
  274. - sendfile: 'on'
  275. - tcp_nopush: 'on'
  276. - tcp_nodelay: 'on'
  277. - send_iowait: 12000
  278. # Use this if you need to deploy below certificates in a custom path.
  279. certificates_path: '/etc/nginx/ssl'
  280. # If you're doing SSL termination, you can deploy certificates this way.
  281. # The private one(s) should go in a separate pillar file not in version
  282. # control (or use encrypted pillar data).
  283. certificates:
  284. 'www.example.com':
  285. # choose one of: deploying this cert by pillar (e.g. in combination with
  286. # ext_pillar and file_tree)
  287. # public_cert_pillar: certs:example.com:fullchain.pem
  288. # private_key_pillar: certs:example.com:privkey.pem
  289. # or directly pasting the cert
  290. public_cert: |
  291. -----BEGIN CERTIFICATE-----
  292. (Your Primary SSL certificate: www.example.com.crt)
  293. -----END CERTIFICATE-----
  294. -----BEGIN CERTIFICATE-----
  295. (Your Intermediate certificate: ExampleCA.crt)
  296. -----END CERTIFICATE-----
  297. -----BEGIN CERTIFICATE-----
  298. (Your Root certificate: TrustedRoot.crt)
  299. -----END CERTIFICATE-----
  300. private_key: |
  301. -----BEGIN RSA PRIVATE KEY-----
  302. (Your Private Key: www.example.com.key)
  303. -----END RSA PRIVATE KEY-----
  304. dh_param:
  305. 'mydhparam1.pem': |
  306. -----BEGIN DH PARAMETERS-----
  307. (Your custom DH prime)
  308. -----END DH PARAMETERS-----
  309. # or to generate one on-the-fly
  310. 'mydhparam2.pem':
  311. keysize: 2048
  312. # Passenger configuration
  313. # Default passenger configuration is provided, and will be deployed in
  314. # /etc/nginx/conf.d/passenger.conf
  315. # Passenger conf can be retrieved by TOFS ( Fallback to nginx.conf )
  316. passenger:
  317. passenger_root: /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  318. passenger_ruby: /usr/bin/ruby
  319. passenger_instance_registry_dir: /var/run/passenger-instreg
  320. tofs:
  321. # The files_switch key serves as a selector for alternative
  322. # directories under the formula files directory. See TOFS pattern
  323. # doc for more info.
  324. # Note: Any value not evaluated by `config.get` will be used literally.
  325. # This can be used to set custom paths, as many levels deep as required.
  326. # files_switch:
  327. # - any/path/can/be/used/here
  328. # - id
  329. # - role
  330. # - osfinger
  331. # - os
  332. # - os_family
  333. #
  334. # All aspects of path/file resolution are customisable using the options below.
  335. # This is unnecessary in most cases; there are sensible defaults.
  336. # Default path: salt://< path_prefix >/< dirs.files >/< dirs.default >
  337. # I.e.: salt://nginx/files/default
  338. # path_prefix: template_alt
  339. # dirs:
  340. # files: files_alt
  341. # default: default_alt
  342. source_files:
  343. nginx_config_file_managed:
  344. - alt_nginx.conf
  345. passenger_config_file_managed:
  346. - alt_nginx.conf
  347. server_conf_file_managed:
  348. - alt_server.conf
  349. nginx_systemd_service_file:
  350. - alt_nginx.service
  351. nginx_snippet_file_managed:
  352. - alt_server.conf