Saltstack Official Nginx Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

387 rindas
14KB

  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 and the rest of
  110. # the options; if it is found other options (worker_processes: 4 and so
  111. # on) are not processed and just upload the file from source
  112. source_path: salt://path_to_nginx_conf_file/nginx.conf
  113. worker_processes: 4
  114. # pass as very first in configuration; otherwise nginx will fail to start
  115. load_module: modules/ngx_http_lua_module.so
  116. # Directory location must exist (i.e. it's /run/nginx.pid on EL7)
  117. # pid: /var/run/nginx.pid
  118. events:
  119. worker_connections: 1024
  120. http:
  121. sendfile: 'on'
  122. include:
  123. #### Note: Syntax issues in these files generate nginx [emerg] errors
  124. #### on startup.
  125. - /etc/nginx/mime.types
  126. ### module ngx_http_log_module example
  127. log_format: |-
  128. main '$remote_addr - $remote_user [$time_local] $status '
  129. '"$request" $body_bytes_sent "$http_referer" '
  130. '"$http_user_agent" "$http_x_forwarded_for"'
  131. access_log: [] # suppress default access_log option from being added
  132. # module nngx_stream_core_module
  133. # yamllint disable-line rule:line-length
  134. # https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/#example
  135. stream:
  136. upstream lb-1000:
  137. - server:
  138. - hostname1.example.com:1000
  139. - hostname2.example.com:1000
  140. upstream stream_backend:
  141. least_conn: ''
  142. 'server backend1.example.com:12345 weight=5': ~
  143. 'server backend2.example.com:12345 max_fails=2 fail_timeout=30s': ~
  144. 'server backend3.example.com:12345 max_conns=3': ~
  145. upstream dns_servers:
  146. least_conn: ''
  147. 'server 192.168.136.130:53': ~
  148. 'server 192.168.136.131:53': ~
  149. 'server 192.168.136.132:53': ~
  150. server:
  151. listen: 1000
  152. proxy_pass: lb-1000
  153. 'server ':
  154. listen: '53 udp'
  155. proxy_pass: dns_servers
  156. 'server ':
  157. listen: 12346
  158. proxy_pass: backend4.example.com:12346
  159. servers:
  160. # a postfix appended to files when doing non-symlink disabling
  161. disabled_postfix: .disabled
  162. # partially exposes file.symlink params when symlinking enabled sites
  163. symlink_opts: {}
  164. # partially exposes file.rename params when not symlinking disabled/enabled sites
  165. rename_opts: {}
  166. # partially exposes file.managed params for managed server files
  167. managed_opts: {}
  168. # partially exposes file.directory params for site available/enabled and
  169. # snippets dirs
  170. dir_opts: {}
  171. # let the choice to purge site-available and site-enable folders before add new ones
  172. # (if True it removes all non-salt-managed files)
  173. purge_servers_config: false
  174. #####################
  175. # server declarations; placed by default in server "available" directory
  176. #####################
  177. managed:
  178. # relative filename of server file
  179. # (defaults to '/etc/nginx/sites-available/mysite')
  180. mysite:
  181. # may be true, false, or None where true is enabled, false, disabled,
  182. # and None indicates no action
  183. enabled: true
  184. # This let's you add dependencies on other resources being applied for a
  185. # particular vhost
  186. # A common case is when you use this formula together with letsencrypt's,
  187. # validating through nginx: you need nginx running (to validate the vhost) but
  188. # can't have the ssl vhost up until the certificate is created (because it
  189. # won't exist and will make nginx fail to load the configuration)
  190. #
  191. # An example, when using LE to create the cert for 'some.host.domain':
  192. # requires:
  193. # cmd: create-initial-cert-some.host.domain
  194. requires: {}
  195. # Remove the site config file shipped by nginx
  196. # (i.e. '/etc/nginx/sites-available/default' by default)
  197. # It also remove the symlink (if it is exists).
  198. # The site MUST be disabled before delete it (if not the nginx is not
  199. # reloaded).
  200. # deleted: true
  201. # custom directory (not sites-available) for server filename
  202. # available_dir: /etc/nginx/sites-available-custom
  203. # custom directory (not sites-enabled) for server filename
  204. # enabled_dir: /etc/nginx/sites-enabled-custom
  205. # an alternative disabled name to be use when not symlinking
  206. disabled_name: mysite.aint_on
  207. # overwrite an existing server file or not
  208. overwrite: true
  209. # May be a list of config options or None, if None, no server file will
  210. # be managed/templated Take server directives as lists of dictionaries.
  211. # If the dictionary value is another list of dictionaries a block {}
  212. # will be started with the dictionary key name
  213. config:
  214. # both of the methods below lead to the output:
  215. # server {
  216. # server_name localhost;
  217. # listen 80 default_server;
  218. # listen 443 ssl;
  219. # index index.html index.htm;
  220. # location ~ .htm {
  221. # try_files $uri $uri/ =404;
  222. # test something else;
  223. # }
  224. # }
  225. - server:
  226. - server_name: localhost
  227. - listen:
  228. - '80 default_server'
  229. - listen:
  230. - '443 ssl'
  231. - index: 'index.html index.htm'
  232. - location ~ .htm:
  233. - try_files: '$uri $uri/ =404'
  234. - test: something else
  235. - include: 'snippets/letsencrypt.conf'
  236. # Or a slightly more compact alternative syntax:
  237. - server:
  238. - server_name: localhost
  239. - listen:
  240. - '80 default_server'
  241. - '443 ssl'
  242. - index: 'index.html index.htm'
  243. - location ~ .htm:
  244. - try_files: '$uri $uri/ =404'
  245. - test: something else
  246. - include: 'snippets/letsencrypt.conf'
  247. # Using source_path options to upload the file instead of templating all the file
  248. mysite2:
  249. enabled: true
  250. available_dir: /etc/nginx/sites-available
  251. enabled_dir: /etc/nginx/sites-enabled
  252. config:
  253. # IMPORTANT: This field is mutually exclusive with TOFS and other
  254. # config options, it just uploads the specified file
  255. source_path: salt://path-to-site-file/mysite2
  256. # Below configuration becomes handy if you want to create custom
  257. # configuration files for example if you want to create
  258. # /usr/local/etc/nginx/http_options.conf with the following content:
  259. # sendfile on;
  260. # tcp_nopush on;
  261. # tcp_nodelay on;
  262. # send_iowait 12000;
  263. http_options.conf:
  264. enabled: true
  265. available_dir: /usr/local/etc/nginx
  266. enabled_dir: /usr/local/etc/nginx
  267. config:
  268. - sendfile: 'on'
  269. - tcp_nopush: 'on'
  270. - tcp_nodelay: 'on'
  271. - send_iowait: 12000
  272. # Use this if you need to deploy below certificates in a custom path.
  273. certificates_path: '/etc/nginx/ssl'
  274. # If you're doing SSL termination, you can deploy certificates this way.
  275. # The private one(s) should go in a separate pillar file not in version
  276. # control (or use encrypted pillar data).
  277. certificates:
  278. 'www.example.com':
  279. # choose one of: deploying this cert by pillar (e.g. in combination with
  280. # ext_pillar and file_tree)
  281. # public_cert_pillar: certs:example.com:fullchain.pem
  282. # private_key_pillar: certs:example.com:privkey.pem
  283. # or directly pasting the cert
  284. public_cert: |
  285. -----BEGIN CERTIFICATE-----
  286. (Your Primary SSL certificate: www.example.com.crt)
  287. -----END CERTIFICATE-----
  288. -----BEGIN CERTIFICATE-----
  289. (Your Intermediate certificate: ExampleCA.crt)
  290. -----END CERTIFICATE-----
  291. -----BEGIN CERTIFICATE-----
  292. (Your Root certificate: TrustedRoot.crt)
  293. -----END CERTIFICATE-----
  294. private_key: |
  295. -----BEGIN RSA PRIVATE KEY-----
  296. (Your Private Key: www.example.com.key)
  297. -----END RSA PRIVATE KEY-----
  298. dh_param:
  299. 'mydhparam1.pem': |
  300. -----BEGIN DH PARAMETERS-----
  301. (Your custom DH prime)
  302. -----END DH PARAMETERS-----
  303. # or to generate one on-the-fly
  304. 'mydhparam2.pem':
  305. keysize: 2048
  306. # Passenger configuration
  307. # Default passenger configuration is provided, and will be deployed in
  308. # /etc/nginx/conf.d/passenger.conf
  309. # Passenger conf can be retrieved by TOFS ( Fallback to nginx.conf )
  310. passenger:
  311. passenger_root: /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  312. passenger_ruby: /usr/bin/ruby
  313. passenger_instance_registry_dir: /var/run/passenger-instreg
  314. tofs:
  315. # The files_switch key serves as a selector for alternative
  316. # directories under the formula files directory. See TOFS pattern
  317. # doc for more info.
  318. # Note: Any value not evaluated by `config.get` will be used literally.
  319. # This can be used to set custom paths, as many levels deep as required.
  320. # files_switch:
  321. # - any/path/can/be/used/here
  322. # - id
  323. # - role
  324. # - osfinger
  325. # - os
  326. # - os_family
  327. #
  328. # All aspects of path/file resolution are customisable using the options below.
  329. # This is unnecessary in most cases; there are sensible defaults.
  330. # Default path: salt://< path_prefix >/< dirs.files >/< dirs.default >
  331. # I.e.: salt://nginx/files/default
  332. # path_prefix: template_alt
  333. # dirs:
  334. # files: files_alt
  335. # default: default_alt
  336. source_files:
  337. nginx_config_file_managed:
  338. - alt_nginx.conf
  339. passenger_config_file_managed:
  340. - alt_nginx.conf
  341. server_conf_file_managed:
  342. - alt_server.conf
  343. nginx_systemd_service_file:
  344. - alt_nginx.service
  345. nginx_snippet_file_managed:
  346. - alt_server.conf