Saltstack Official Nginx Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

284 行
11KB

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