Saltstack Official Nginx Formula
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

268 lines
11KB

  1. # nginx:
  2. install_from_source: True
  3. use_upstart: True
  4. use_sysvinit: False
  5. user_auth_enabled: True
  6. with_luajit: False
  7. with_openresty: True
  8. repo_version: development # Must be using ppa install by setting `repo_source = ppa`
  9. set_real_ips: # NOTE: to use this, nginx must have http_realip module enabled
  10. from_ips:
  11. - 10.10.10.0/24
  12. real_ip_header: X-Forwarded-For
  13. modules:
  14. headers-more:
  15. source: http://github.com/agentzh/headers-more-nginx-module/tarball/v0.21
  16. source_hash: sha1=dbf914cbf3f7b6cb7e033fa7b7c49e2f8879113b
  17. # ========
  18. # nginx.ng
  19. # ========
  20. nginx:
  21. ng:
  22. # The following three `install_from_` options are mutually exclusive. If none is used, the distro's provided
  23. # package will be installed. If one of the `install_from` option is set to `True`, the state will
  24. # make sure the other two repos are removed.
  25. # Use the official's nginx repo binaries
  26. install_from_repo: false
  27. # Use Phusionpassenger's repo to install nginx and passenger binaries
  28. # Debian, Centos, Ubuntu and Redhat are currently available
  29. install_from_phusionpassenger: false
  30. # PPA install
  31. install_from_ppa: false
  32. # Set to 'stable', 'development' (mainline), 'community', or 'nightly' for each build accordingly ( https://launchpad.net/~nginx )
  33. ppa_version: 'stable'
  34. # Source install
  35. source_version: '1.10.0'
  36. source_hash: ''
  37. # These are usually set by grains in map.jinja
  38. # Typically you can comment these out.
  39. lookup:
  40. package: nginx-custom (can be a list)
  41. service: nginx
  42. webuser: www-data
  43. conf_file: /etc/nginx/nginx.conf
  44. server_available: /etc/nginx/sites-available
  45. server_enabled: /etc/nginx/sites-enabled
  46. server_use_symlink: True
  47. # If you install nginx+passenger from phusionpassenger in Debian, these values will probably be needed
  48. passenger_package: libnginx-mod-http-passenger
  49. passenger_config_file: /etc/nginx/conf.d/mod-http-passenger.conf
  50. # This is required for RedHat like distros (Amazon Linux) that don't follow 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. pid_file: /var/run/nginx.pid ### Prevent Rendering SLS error (map.jinja:149) if nginx.server.config.pid undefined (Ubuntu, etc) ###
  55. # Source compilation is not currently a part of nginx.ng
  56. from_source: False
  57. source:
  58. opts: {}
  59. package:
  60. opts: {} # this partially exposes parameters of pkg.installed
  61. service:
  62. enable: True # Whether or not the service will be enabled/running or dead
  63. opts: {} # this partially exposes parameters of service.running / service.dead
  64. snippets: # You can use snippets to define often repeated configuration once and include it later
  65. letsencrypt: # e.g. this can be included using "- include: 'snippets/letsencrypt.conf'"
  66. - location ^~ /.well-known/acme-challenge/:
  67. - proxy_pass: http://localhost:9999
  68. server:
  69. opts: {} # this partially exposes file.managed parameters as they relate to the main nginx.conf file
  70. # nginx.conf (main server) declarations
  71. # dictionaries map to blocks {} and lists cause the same declaration to repeat with different values
  72. # see also http://nginx.org/en/docs/example.html
  73. config:
  74. source_path: salt://path_to_nginx_conf_file/nginx.conf # IMPORTANT: This option is mutually exclusive with the rest of the
  75. # options; if it is found other options (worker_processes: 4 and so
  76. # on) are not processed and just upload the file from source
  77. worker_processes: 4
  78. load_module: modules/ngx_http_lua_module.so # this will be passed very first in configuration; otherwise nginx will fail to start
  79. pid: /var/run/nginx.pid # Directory location must exist
  80. events:
  81. worker_connections: 768
  82. http:
  83. sendfile: 'on'
  84. include:
  85. #### Note: Syntax issues in these files generate nginx [emerg] errors on startup. ####
  86. - /etc/nginx/mime.types
  87. - /etc/nginx/conf.d/*.conf
  88. - /etc/nginx/sites-enabled/*
  89. ### module ngx_http_log_module example
  90. log_format: |-
  91. main '...';
  92. access_log /var/log/nginx/access_log main
  93. access_log: [] #suppress default access_log option from being added
  94. ### module nngx_stream_core_module
  95. ### https://docs.nginx.com/nginx/admin-guide/load-balancer/tcp-udp-load-balancer/#example
  96. stream:
  97. upstream lb-1000:
  98. - server:
  99. - hostname1.example.com:1000
  100. - hostname2.example.com:1000
  101. server:
  102. listen: 1000
  103. proxy_pass: lb-1000
  104. upstream stream_backend:
  105. least_conn: ''
  106. 'server': 'backend1.example.com:12345 weight=5' #one way
  107. 'server backend2.example.com:12345 max_fails=2 fail_timeout=30s': ''
  108. 'server backend3.example.com:12345 max_conns=3': '' #another way
  109. upstream dns_servers:
  110. least_conn:
  111. 'server 192.168.136.130:53': ''
  112. 'server 192.168.136.131:53': ''
  113. 'server 192.168.136.132:53': ''
  114. 'server ':
  115. listen: '53 udp'
  116. proxy_pass: dns_servers
  117. 'server ':
  118. listen: 12346
  119. proxy_pass: backend4.example.com:12346
  120. servers:
  121. disabled_postfix: .disabled # a postfix appended to files when doing non-symlink disabling
  122. symlink_opts: {} # partially exposes file.symlink params when symlinking enabled sites
  123. rename_opts: {} # partially exposes file.rename params when not symlinking disabled/enabled sites
  124. managed_opts: {} # partially exposes file.managed params for managed server files
  125. dir_opts: {} # partially exposes file.directory params for site available/enabled and snippets dirs
  126. #####################
  127. # server declarations; placed by default in server "available" directory
  128. #####################
  129. managed:
  130. mysite: # relative filename of server file (defaults to '/etc/nginx/sites-available/mysite')
  131. # may be True, False, or None where True is enabled, False, disabled, and None indicates no action
  132. enabled: True
  133. # Remove the site config file shipped by nginx (i.e. '/etc/nginx/sites-available/default' by default)
  134. # It also remove the symlink (if it is exists).
  135. # The site MUST be disabled before delete it (if not the nginx is not reloaded).
  136. #deleted: True
  137. #available_dir: /etc/nginx/sites-available-custom # custom directory (not sites-available) for server filename
  138. #enabled_dir: /etc/nginx/sites-enabled-custom # custom directory (not sites-enabled) for server filename
  139. disabled_name: mysite.aint_on # an alternative disabled name to be use when not symlinking
  140. overwrite: True # overwrite an existing server file or not
  141. # May be a list of config options or None, if None, no server file will be managed/templated
  142. # Take server directives as lists of dictionaries. If the dictionary value is another list of
  143. # dictionaries a block {} will be started with the dictionary key name
  144. config:
  145. - server:
  146. - server_name: localhost
  147. - listen:
  148. - 80
  149. - default_server
  150. - index:
  151. - index.html
  152. - index.htm
  153. - location ~ .htm:
  154. - try_files:
  155. - $uri
  156. - $uri/ =404
  157. - test: something else
  158. - include 'snippets/letsencrypt.conf'
  159. # The above outputs:
  160. # server {
  161. # server_name localhost;
  162. # listen 80 default_server;
  163. # index index.html index.htm;
  164. # location ~ .htm {
  165. # try_files $uri $uri/ =404;
  166. # test something else;
  167. # }
  168. # }
  169. mysite2: # Using source_path options to upload the file instead of templating all the file
  170. enabled: True
  171. available_dir: /etc/nginx/sites-available
  172. enabled_dir: /etc/nginx/sites-enabled
  173. config:
  174. source_path: salt://path-to-site-file/mysite2
  175. # Below configuration becomes handy if you want to create custom configuration files
  176. # for example if you want to create /usr/local/etc/nginx/http_options.conf with
  177. # the following content:
  178. # sendfile on;
  179. # tcp_nopush on;
  180. # tcp_nodelay on;
  181. # send_iowait 12000;
  182. http_options.conf:
  183. enabled: True
  184. available_dir: /usr/local/etc/nginx
  185. enabled_dir: /usr/local/etc/nginx
  186. config:
  187. - sendfile: 'on'
  188. - tcp_nopush: 'on'
  189. - tcp_nodelay: 'on'
  190. - send_iowait: 12000
  191. certificates_path: '/etc/nginx/ssl' # Use this if you need to deploy below certificates in a custom path.
  192. # If you're doing SSL termination, you can deploy certificates this way.
  193. # The private one(s) should go in a separate pillar file not in version
  194. # control (or use encrypted pillar data).
  195. certificates:
  196. 'www.example.com':
  197. # choose one of: deploying this cert by pillar (e.g. in combination with ext_pillar and file_tree)
  198. # public_cert_pillar: certs:example.com:fullchain.pem
  199. # private_key_pillar: certs:example.com:privkey.pem
  200. # or directly pasting the cert
  201. public_cert: |
  202. -----BEGIN CERTIFICATE-----
  203. (Your Primary SSL certificate: www.example.com.crt)
  204. -----END CERTIFICATE-----
  205. -----BEGIN CERTIFICATE-----
  206. (Your Intermediate certificate: ExampleCA.crt)
  207. -----END CERTIFICATE-----
  208. -----BEGIN CERTIFICATE-----
  209. (Your Root certificate: TrustedRoot.crt)
  210. -----END CERTIFICATE-----
  211. private_key: |
  212. -----BEGIN RSA PRIVATE KEY-----
  213. (Your Private Key: www.example.com.key)
  214. -----END RSA PRIVATE KEY-----
  215. dh_param:
  216. 'mydhparam1.pem': |
  217. -----BEGIN DH PARAMETERS-----
  218. (Your custom DH prime)
  219. -----END DH PARAMETERS-----
  220. # or to generate one on-the-fly
  221. 'mydhparam2.pem':
  222. keysize: 2048
  223. # Passenger configuration
  224. # Default passenger configuration is provided, and will be deployed in
  225. # /etc/nginx/conf.d/passenger.conf
  226. passenger:
  227. passenger_root: /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini
  228. passenger_ruby: /usr/bin/ruby
  229. passenger_instance_registry_dir: /var/run/passenger-instreg