Saltstack Official Nginx Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

360 linhas
13KB

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