-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.sls
75 lines (70 loc) · 2.62 KB
/
server.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{% from "http_proxy/defaults.jinja" import settings with context %}
trafficserver:
pkg.installed:
- pkgs:
- trafficserver
service.running:
- enable: True
- require:
- pkg: trafficserver
- file: {{ settings.cache_dir }}
{{ settings.cache_dir }}:
file.directory:
- user: trafficserver
- group: trafficserver
- makedirs: true
- require:
- pkg: trafficserver
{#
# ubuntu has trafficserver 8.x
# documentation: https://docs.trafficserver.apache.org/en/8.0.x/index.html
# configuration advice see: https://cwiki.apache.org/confluence/display/TS/WebProxyCacheTuning
# listening interfaces
# listening port
# enable caching forward proxy
# no url_remap required to use ts as caching forward proxy
# disable reverse proxy
# cache objects have 1 to 4 weeks lifetime
# limit connections to 1K (default 30K)
# limit idle cpu usage via epoll_wait timeout in ms (default 10)
# limit threads to 4 (default cores*1.5)
# limit hostdb size to 8mb
# main memory used for cache index
#}
{% set ip_list=[settings.listen_ip,] if settings.listen_ip is string else settings.listen_ip %}
{% set config_list= [
('LOCAL', 'proxy.local.incoming_ip_to_bind STRING', ip_list|join(' ')),
('CONFIG', 'proxy.config.http.server_ports STRING', settings.listen_port),
('CONFIG', 'proxy.config.http.cache.http INT', '1'),
('CONFIG', 'proxy.config.url_remap.remap_required INT' , '0'),
('CONFIG', 'proxy.config.reverse_proxy.enabled INT', '0'),
('CONFIG', 'proxy.config.http.cache.heuristic_min_lifetime INT', '604800'),
('CONFIG', 'proxy.config.http.cache.heuristic_max_lifetime INT', '2419200'),
('CONFIG', 'proxy.config.net.connections_throttle INT', '1000'),
('CONFIG', 'proxy.config.net.poll_timeout INT', '200'),
('CONFIG', 'proxy.config.exec_thread.autoconfig INT', '0'),
('CONFIG', 'proxy.config.exec_thread.limit INT', '4'),
('CONFIG', 'proxy.config.hostdb.max_size INT', '8M'),
('CONFIG', 'proxy.config.cache.ram_cache.size INT', settings.memory_cache_size_mb|string ~ 'M'),
] %}
{% for section,item,value in config_list %}
ATS_{{ section }}_{{ item }}:
file.replace:
- name: /etc/trafficserver/records.config
- pattern: "^{{ section }} {{ item }}.+"
- repl: {{ section }} {{ item }} {{ value }}
- append_if_not_found: true
- require:
- pkg: trafficserver
- watch_in:
- service: trafficserver
{% endfor %}
/etc/trafficserver/storage.config:
file.replace:
- pattern: "^/[^ ]+ [0-9]+M"
- repl: {{ settings.cache_dir }} {{ settings.cache_size_mb }}M
- append_if_not_found: true
- require:
- pkg: trafficserver
- watch_in:
- service: trafficserver