Saltstack Official Nginx Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
10 yıl önce
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. {% set nginx = pillar.get('nginx', {}) -%}
  2. # defaults passed via context from the map.jinja
  3. {% set user = nginx.get('user', default_user) -%}
  4. {% set group = nginx.get('group', default_group) -%}
  5. user {{ user }} {{ group }};
  6. worker_processes {{ nginx.get('worker_processes', 1) }};
  7. {% set worker_rlimit_nofile = nginx.get('worker_rlimit_nofile', '') -%}
  8. {% if worker_rlimit_nofile -%}
  9. worker_rlimit_nofile {{ worker_rlimit_nofile }};
  10. {% endif -%}
  11. {% set error_log_location = nginx.get('error_log',{}).get('location', '/var/log/nginx/error.fifo') -%}
  12. {% set error_log_level = nginx.get('error_log',{}).get('level', 'warn') -%}
  13. error_log {{ ' '.join([error_log_location, error_log_level]) }};
  14. pid {{ nginx.get('pid', '/var/run/nginx.pid') }};
  15. {% if salt['test.provider']('service') != 'systemd' -%}
  16. daemon {{ nginx.get('daemon', 'on') }};
  17. {%- endif %}
  18. events {
  19. worker_connections {{ nginx.get('events', {}).get('worker_connections', 1024) }};
  20. {% set use = nginx.get('events', {}).get('use', '') -%}
  21. {% if use -%}
  22. use {{ use }};
  23. {% endif %}
  24. }
  25. http {
  26. {% if 'set_real_ips' in nginx -%}
  27. {% for ip in nginx.get('set_real_ips', {}).get('from_ips', []) -%}
  28. set_real_ip_from {{ ip }};
  29. {% endfor -%}
  30. real_ip_header {{ nginx.get('set_real_ips', {}).get('real_ip_header', 'X-Forwarded-For') }};
  31. {% endif -%}
  32. include /etc/nginx/mime.types;
  33. default_type {{ nginx.get('default_type', 'application/octet-stream') }};
  34. log_format main '$scheme://$host:$server_port$uri$is_args$args $remote_addr:$remote_user "$request" $request_time $request_length:$bytes_sent $status "$http_referer" "$http_user_agent" "$http_x_forwarded_for"';
  35. access_log /var/log/nginx/access.fifo main;
  36. sendfile {{ nginx.get('sendfile', 'on') }};
  37. #tcp_nopush on;
  38. keepalive_timeout {{ nginx.get('keepalive_timeout', 65) }};
  39. server_names_hash_bucket_size {{ nginx.get('server_names_hash_bucket_size', 128) }};
  40. server_names_hash_max_size {{ nginx.get('server_names_hash_max_size', 1024) }};
  41. types_hash_max_size {{ nginx.get('types_hash_max_size', 8192) }};
  42. gzip {{ nginx.get('gzip', 'on') }};
  43. gzip_vary {{ nginx.get('gzip_vary', 'on') }};
  44. gzip_proxied {{ nginx.get('gzip_proxied', 'any') }};
  45. gzip_comp_level {{ nginx.get('gzip_comp_level', 6) }};
  46. gzip_buffers {{ nginx.get('gzip_buffers', '16 8k') }};
  47. gzip_http_version {{ nginx.get('gzip_http_version', '1.1') }};
  48. gzip_types {{ nginx.get('gzip_types', ['text/plain', 'text/css', 'application/json', 'application/x-javascript', 'text/xml', 'application/xml', 'application/xml+rss', 'text/javascript'])|join(' ') }};
  49. gzip_disable "{{ nginx.get('gzip_disable', 'msie6') }}";
  50. # turn on nginx_status on localhost
  51. server {
  52. listen 127.0.0.1:80;
  53. server_name 127.0.0.1;
  54. location /nginx_status {
  55. stub_status on;
  56. access_log off;
  57. allow 127.0.0.1;
  58. deny all;
  59. }
  60. }
  61. {% if pillar['nginx'] is defined -%}
  62. {% if pillar['nginx']['redirect_numeric_ip']|default(False) -%}
  63. server {
  64. server_name {% for ip in salt['network.interfaces']()['eth0']['inet'] %}{{ ip['address'] }}:80{% if not loop.last %} {% endif %}{% endfor %};
  65. return 302 {{ pillar['nginx']['redirect_numeric_ip'] }};
  66. access_log off;
  67. }
  68. {% endif -%}
  69. {% endif %}
  70. include /etc/nginx/conf.d/*.conf;
  71. include /etc/nginx/sites-enabled/*.conf;
  72. }