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

10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
10 лет назад
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {% set nginx = pillar.get('nginx', {}) -%}
  2. {% set user = nginx.get('user', 'www-data') -%}
  3. {% set group = nginx.get('group', 'www-data') -%}
  4. user {{ user }} {{ group }};
  5. worker_processes {{ nginx.get('worker_processes', 1) }};
  6. {% set worker_rlimit_nofile = nginx.get('worker_rlimit_nofile', '') -%}
  7. {% if worker_rlimit_nofile -%}
  8. worker_rlimit_nofile {{ worker_rlimit_nofile }};
  9. {% endif -%}
  10. {% set error_log_location = nginx.get('error_log',{}).get('location', '/var/log/nginx/error.log') -%}
  11. {% set error_log_level = nginx.get('error_log',{}).get('level', 'warn') -%}
  12. error_log {{ ' '.join([error_log_location, error_log_level]) }};
  13. pid {{ nginx.get('pid', '/var/run/nginx.pid') }};
  14. daemon {{ nginx.get('daemon', 'on') }};
  15. events {
  16. worker_connections {{ nginx.get('events', {}).get('worker_connections', 1024) }};
  17. {% set use = nginx.get('events', {}).get('use', '') -%}
  18. {% if use -%}
  19. use {{ use }};
  20. {% endif %}
  21. }
  22. http {
  23. include /etc/nginx/mime.types;
  24. default_type {{ nginx.get('default_type', 'application/octet-stream') }};
  25. 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"';
  26. access_log /var/log/nginx/access.fifo main;
  27. sendfile {{ nginx.get('sendfile', 'on') }};
  28. #tcp_nopush on;
  29. keepalive_timeout {{ nginx.get('keepalive_timeout', 65) }};
  30. server_names_hash_bucket_size {{ nginx.get('server_names_hash_bucket_size', 128) }};
  31. server_names_hash_max_size {{ nginx.get('server_names_hash_max_size', 1024) }};
  32. types_hash_max_size {{ nginx.get('types_hash_max_size', 8192) }};
  33. gzip {{ nginx.get('gzip', 'on') }};
  34. gzip_vary {{ nginx.get('gzip_vary', 'on') }};
  35. gzip_proxied {{ nginx.get('gzip_proxied', 'any') }};
  36. gzip_comp_level {{ nginx.get('gzip_comp_level', 6) }};
  37. gzip_buffers {{ nginx.get('gzip_buffers', '16 8k') }};
  38. gzip_http_version {{ nginx.get('gzip_http_version', '1.1') }};
  39. 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(' ') }};
  40. gzip_disable "{{ nginx.get('gzip_disable', 'msie6') }}";
  41. # turn on nginx_status on localhost
  42. server {
  43. listen 127.0.0.1:80;
  44. server_name 127.0.0.1;
  45. location /nginx_status {
  46. stub_status on;
  47. access_log off;
  48. allow 127.0.0.1;
  49. deny all;
  50. }
  51. }
  52. {% if pillar['nginx'] is defined -%}
  53. {% if pillar['nginx']['redirect_numeric_ip']|default(False) -%}
  54. server {
  55. server_name {% for ip in salt['network.interfaces']()['eth0']['inet'] %}{{ ip['address'] }}:80{% if not loop.last %} {% endif %}{% endfor %};
  56. return 302 {{ pillar['nginx']['redirect_numeric_ip'] }};
  57. access_log off;
  58. }
  59. {% endif -%}
  60. {% endif %}
  61. include /etc/nginx/conf.d/*.conf;
  62. include /etc/nginx/sites-enabled/*.conf;
  63. }