Saltstack Official Nginx Formula
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

383 Zeilen
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. # This let's you add dependencies on other resources being applied for a
  182. # particular vhost
  183. # A common case is when you use this formula together with letsencrypt's,
  184. # validating through nginx: you need nginx running (to validate the vhost) but
  185. # can't have the ssl vhost up until the certificate is created (because it
  186. # won't exist and will make nginx fail to load the configuration)
  187. #
  188. # An example, when using LE to create the cert for 'some.host.domain':
  189. # requires:
  190. # cmd: create-initial-cert-some.host.domain
  191. requires: {}
  192. # Remove the site config file shipped by nginx
  193. # (i.e. '/etc/nginx/sites-available/default' by default)
  194. # It also remove the symlink (if it is exists).
  195. # The site MUST be disabled before delete it (if not the nginx is not
  196. # reloaded).
  197. # deleted: true
  198. # custom directory (not sites-available) for server filename
  199. # available_dir: /etc/nginx/sites-available-custom
  200. # custom directory (not sites-enabled) for server filename
  201. # enabled_dir: /etc/nginx/sites-enabled-custom
  202. # an alternative disabled name to be use when not symlinking
  203. disabled_name: mysite.aint_on
  204. # overwrite an existing server file or not
  205. overwrite: true
  206. # May be a list of config options or None, if None, no server file will
  207. # be managed/templated Take server directives as lists of dictionaries.
  208. # If the dictionary value is another list of dictionaries a block {}
  209. # will be started with the dictionary key name
  210. config:
  211. # both of the methods below lead to the output:
  212. # server {
  213. # server_name localhost;
  214. # listen 80 default_server;
  215. # listen 443 ssl;
  216. # index index.html index.htm;
  217. # location ~ .htm {
  218. # try_files $uri $uri/ =404;
  219. # test something else;
  220. # }
  221. # }
  222. - server:
  223. - server_name: localhost
  224. - listen:
  225. - '80 default_server'
  226. - listen:
  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. # Or a slightly more compact alternative syntax:
  234. - server:
  235. - server_name: localhost
  236. - listen:
  237. - '80 default_server'
  238. - '443 ssl'
  239. - index: 'index.html index.htm'
  240. - location ~ .htm:
  241. - try_files: '$uri $uri/ =404'
  242. - test: something else
  243. - include: 'snippets/letsencrypt.conf'
  244. # Using source_path options to upload the file instead of templating all the file
  245. mysite2:
  246. enabled: true
  247. available_dir: /etc/nginx/sites-available
  248. enabled_dir: /etc/nginx/sites-enabled
  249. config:
  250. # IMPORTANT: This field is mutually exclusive with TOFS and other
  251. # config options, it just uploads the specified file
  252. source_path: salt://path-to-site-file/mysite2
  253. # Below configuration becomes handy if you want to create custom
  254. # configuration files for example if you want to create
  255. # /usr/local/etc/nginx/http_options.conf with the following content:
  256. # sendfile on;
  257. # tcp_nopush on;
  258. # tcp_nodelay on;
  259. # send_iowait 12000;
  260. http_options.conf:
  261. enabled: true
  262. available_dir: /usr/local/etc/nginx
  263. enabled_dir: /usr/local/etc/nginx
  264. config:
  265. - sendfile: 'on'
  266. - tcp_nopush: 'on'
  267. - tcp_nodelay: 'on'
  268. - send_iowait: 12000
  269. # Use this if you need to deploy below certificates in a custom path.
  270. certificates_path: '/etc/nginx/ssl'
  271. # If you're doing SSL termination, you can deploy certificates this way.
  272. # The private one(s) should go in a separate pillar file not in version
  273. # control (or use encrypted pillar data).
  274. certificates:
  275. 'www.example.com':
  276. # choose one of: deploying this cert by pillar (e.g. in combination with
  277. # ext_pillar and file_tree)
  278. # public_cert_pillar: certs:example.com:fullchain.pem
  279. # private_key_pillar: certs:example.com:privkey.pem
  280. # or directly pasting the cert
  281. public_cert: |
  282. -----BEGIN CERTIFICATE-----
  283. (Your Primary SSL certificate: www.example.com.crt)
  284. -----END CERTIFICATE-----
  285. -----BEGIN CERTIFICATE-----
  286. (Your Intermediate certificate: ExampleCA.crt)
  287. -----END CERTIFICATE-----
  288. -----BEGIN CERTIFICATE-----
  289. (Your Root certificate: TrustedRoot.crt)
  290. -----END CERTIFICATE-----
  291. private_key: |
  292. -----BEGIN RSA PRIVATE KEY-----
  293. (Your Private Key: www.example.com.key)
  294. -----END RSA PRIVATE KEY-----
  295. dh_param:
  296. 'mydhparam1.pem': |
  297. -----BEGIN DH PARAMETERS-----
  298. (Your custom DH prime)
  299. -----END DH PARAMETERS-----
  300. # or to generate one on-the-fly
  301. 'mydhparam2.pem':
  302. keysize: 2048
  303. # Passenger configuration
  304. # Default passenger configuration is provided, and will be deployed in
  305. # /etc/nginx/conf.d/passenger.conf
  306. # Passenger conf can be retrieved by TOFS ( Fallback to nginx.conf )
  307. passenger:
  308. passenger_root: /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  309. passenger_ruby: /usr/bin/ruby
  310. passenger_instance_registry_dir: /var/run/passenger-instreg
  311. tofs:
  312. # The files_switch key serves as a selector for alternative
  313. # directories under the formula files directory. See TOFS pattern
  314. # doc for more info.
  315. # Note: Any value not evaluated by `config.get` will be used literally.
  316. # This can be used to set custom paths, as many levels deep as required.
  317. # files_switch:
  318. # - any/path/can/be/used/here
  319. # - id
  320. # - role
  321. # - osfinger
  322. # - os
  323. # - os_family
  324. #
  325. # All aspects of path/file resolution are customisable using the options below.
  326. # This is unnecessary in most cases; there are sensible defaults.
  327. # Default path: salt://< path_prefix >/< dirs.files >/< dirs.default >
  328. # I.e.: salt://nginx/files/default
  329. # path_prefix: template_alt
  330. # dirs:
  331. # files: files_alt
  332. # default: default_alt
  333. source_files:
  334. nginx_config_file_managed:
  335. - alt_nginx.conf
  336. passenger_config_file_managed:
  337. - alt_nginx.conf
  338. server_conf_file_managed:
  339. - alt_server.conf
  340. nginx_systemd_service_file:
  341. - alt_nginx.service
  342. nginx_snippet_file_managed:
  343. - alt_server.conf