Saltstack Official Nginx Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

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