Saltstack Official Nginx Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

59 rindas
2.4KB

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