-
Notifications
You must be signed in to change notification settings - Fork 73
/
converge.yml
798 lines (792 loc) · 29.6 KB
/
converge.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
---
- name: Converge
hosts: all
tasks:
- name: Configure NGINX
ansible.builtin.include_role:
name: ansible-role-nginx-config
vars:
nginx_config_debug_output: true
nginx_config_upload_ssl_enable: true
nginx_config_upload_ssl_crt:
- src: ../common/files/ssl/molecule.crt
dest: /etc/ssl/certs
nginx_config_upload_ssl_key:
- src: ../common/files/ssl/molecule.key
dest: /etc/ssl/private
nginx_config_main_template_enable: true
nginx_config_main_template:
template_file: nginx.conf.j2
deployment_location: /etc/nginx/nginx.conf
config:
main:
# load_module:
# - modules/ngx_http_app_protect_module.so
# - modules/ngx_http_app_protect_dos_module.so
user: nginx
worker_processes: auto
error_log:
- file: /var/log/nginx/error.log
level: notice
pid: /var/run/nginx.pid
worker_rlimit_nofile: 2048
events:
worker_connections: 1024
http:
include:
- /etc/nginx/conf.d/*.conf
stream:
include:
- /etc/nginx/conf.d/stream/*.conf
nginx_config_rest_api_enable: true
nginx_config_rest_api_backup: true
nginx_config_rest_api_write: true
nginx_config_rest_api_access_log:
path: /var/log/nginx/access.log
format: main
nginx_config_rest_api_dashboard: true
nginx_config_http_template_enable: true
nginx_config_http_template:
- template_file: http/default.conf.j2
deployment_location: /etc/nginx/conf.d/default.conf
config:
upstreams:
- name: frontend_servers
zone:
name: frontend_mem_zone
size: 64k
least_time:
response: last_byte
inflight: false
ntlm: true
queue:
number: 10
timeout: 60s
keepalive: 32
keepalive_requests: 100
keepalive_timeout: 60s
sticky_route:
- $cookie_jsessionid
- $request_uri
servers:
- address: 0.0.0.0:8081
- name: backend_servers
zone:
name: backend_mem_zone
size: 64k
random:
two: true
method: least_time=last_byte
sticky_learn:
create:
- $upstream_cookie_example_cookie
- $upstream_cookie_example_biscuit
lookup:
- $cookie_example_cookie
zone:
name: client_sessions
size: 1m
timeout: 10m
header: false
sync: false
resolver:
address:
- 127.0.0.1
valid: 30s
ipv6: false
status_zone: backend_mem_zone
resolver_timeout: 30s
servers:
- address: 0.0.0.0:8082
weight: 1
- address: unix:/var/run/control.unit.sock
weight: 1
- address: 0.0.0.0:8083
down: true
- address: example.com
weight: 1
max_conns: 0
max_fails: 1
fail_timeout: 10s
backup: false
down: false
resolve: true
route: cookie
service: http
slow_start: 0s
drain: false
proxy:
cache_path:
- path: /var/cache/nginx/proxy/frontend
levels: "1:1"
use_temp_path: false
inactive: 10m
keys_zone:
name: frontend_proxy_cache
size: 10m
max_size: 2g
min_free: 1g
manager_files: 100
manager_sleep: 500ms
manager_threshold: 200ms
loader_files: 100
loader_sleep: 50ms
loader_threshold: 200ms
purger: false
purger_files: 10
purger_sleep: 50ms
purger_threshold: 50ms
- path: /var/cache/nginx/proxy/backend
levels: "1:2"
use_temp_path: true
keys_zone:
name: backend_proxy_cache
size: 10m
inactive: 60m
max_size: 10g
core:
default_type: application/octet-stream
keepalive_timeout: 65s
# app_protect_waf:
# physical_memory_util_thresholds:
# high: 100
# low: 100
# cpu_thresholds:
# high: 100
# low: 100
# failure_mode_action: pass
# cookie_seed: testseed
# compressed_requests_action: drop
# app_protect_dos:
# liveliness:
# enable: true
# uri: /app_protect_dos_liveliness
# port: 8090
# readiness:
# enable: true
# uri: /app_protect_dos_readiness
# port: 8090
# arb_fqdn: 192.168.1.10
# accelerated_mitigation: false
grpc:
bind:
address: $remote_addr
transparent: false
buffer_size: 4k
connect_timeout: 60s
hide_header:
- X-Accel-Redirect
ignore_headers:
- X-Accel-Redirect
intercept_errors: false
next_upstream:
- timeout
next_upstream_timeout: 0
next_upstream_tries: 0
pass_header:
- X-Accel-Charset
read_timeout: 60s
send_timeout: 60s
set_header:
- field: Accept-Encoding
value: '""'
socket_keepalive: false
gunzip:
enable: true
buffers:
number: 32
size: 4k
gzip:
enable: true
buffers:
number: 32
size: 4k
comp_level: 1
disable:
- '"msie6"'
http_version: 1.1
min_length: 20
proxied:
- expired
vary: false
auth_jwt:
enable: false
claim_set:
- variable: $email
name:
- info
header_set:
variable: $job
name: info
leeway: 0s
type: nested
require:
values: $jwt_claim_iss
error: 403
auth_request:
uri: false
set:
variable: $temp
value: auth
auth_basic:
realm: false
autoindex:
enable: true
exact_size: true
format: html
localtime: true
health_check:
match:
- name: nginx
conditions:
- status 200
keyval:
keyvals:
- key: $arg_text
variable: $text
zone: key
zones:
- name: key
size: 10m
state: /var/lib/nginx/state/key.keyval
timeout: 2h
type: string
sync: false
headers:
add_headers:
- name: Strict-Transport-Security
value: '"max-age=15768000; includeSubDomains"'
always: true
add_trailers:
- name: Strict-Transport-Security
value: '"max-age=15768000; includeSubDomains"'
always: true
expires:
modified: true
time: 12h
limit_req:
limit_reqs:
- zone: one
burst: 5
delay: false
dry_run: false
log_level: info
status: 503
zones:
- key: $binary_remote_addr
name: one
size: 1m
rate: 10r/s
log:
access:
- path: /var/log/nginx/access.log
format: main
format:
- name: main
format: |
'$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
open_log_file_cache:
max: 1000
inactive: 20s
min_uses: 2
valid: 1m
map:
hash_bucket_size: 128
hash_max_size: 4096
mappings:
- string: $http_host
variable: $name
hostnames: true
volatile: true
content:
- value: example.com
new_value: 1
- string: $http_user_agent
variable: $isblockaccess_ua
content:
- value: default
new_value: 0
- value: '"~jndi:ldap"'
new_value: 1
realip:
set_real_ip_from: 0.0.0.0
real_ip_header: X-Real-IP
real_ip_recursive: false
rewrite:
log: false
uninitialized_variable_warn: false
split_clients:
string: $remote_addr
variable: $upstream_split
content:
- percentage: 20%
value: appv2
- percentage: "*"
value: app
sub_filter:
sub_filters:
- string: server_hostname
replacement: $hostname
last_modified: false
once: false
types: text/html
servers:
- core:
listen:
- address: 0.0.0.0
port: 80
default_server: true
- address: 0.0.0.0
port: 443
ssl: false
default_server: true
- address: "[::]"
port: 80
default_server: true
server_name: localhost
client_max_body_size: 512k
# app_protect_waf:
# enable: true
# policy_file: /etc/app_protect/conf/NginxDefaultPolicy.json
# security_log_enable: true
# security_log:
# - path: /etc/app_protect/conf/log_default.json
# dest: syslog:server=10.1.1.1:514
# - path: /etc/app_protect/conf/log_default.json
# dest: syslog:server=10.1.1.2:514
# app_protect_dos:
# enable: true
# policy_file: /etc/app_protect/conf/BADOSDefaultPolicy.json
# security_log_enable: true
# security_log:
# path: /etc/app_protect_dos/log-default.json
# dest: syslog:server=10.1.1.1:514
# monitor:
# uri: http://10.1.1.1:5000/monitor
# protocol: http2
# timeout: 10
auth_jwt:
enable:
realm: realm
token: $cookie_auth_token
leeway: 0s
type: signed
auth_request:
uri: false
set:
variable: $temp
value: auth
auth_basic:
realm: false
log:
access:
- path: /var/log/nginx/access.log
format: main
locations:
- location: /
# app_protect_waf:
# enable: true
# policy_file: /etc/app_protect/conf/NginxDefaultPolicy.json
# security_log_enable: true
# security_log:
# - path: /etc/app_protect/conf/log_default.json
# dest: syslog:server=10.1.1.1:514
# - path: /etc/app_protect/conf/log_default.json
# dest: syslog:server=10.1.1.2:514
# app_protect_dos:
# enable: true
# policy_file: /etc/app_protect/conf/BADOSDefaultPolicy.json
# security_log_enable: true
# security_log:
# path: /etc/app_protect_dos/log-default.json
# dest: syslog:server=10.1.1.1:514
# monitor: http://10.1.1.1:5000/monitor
# api: true
auth_jwt:
enable: false
leeway: 0s
type: signed
auth_request:
uri: false
set:
variable: $temp
value: auth
auth_basic:
realm: false
health_check:
health_checks:
- interval: 5
jitter: 0
fails: 1
passes: 1
uri: /
mandatory: false
persistent: false
match: nginx
port: 80
keepalive_time: 0
proxy:
bind: false
buffer_size: 4k
buffering: true
buffers:
number: 8
size: 4k
busy_buffers_size: 8k
cache: false
cache_background_update: false
cache_bypass:
- - $cookie_nocache
- $arg_nocache$arg_comment
- $cookie_test
cache_convert_head: true
cache_key: $scheme$proxy_host$request_uri
cache_lock: false
cache_lock_age: 5s
cache_lock_timeout: 5s
cache_max_range_offset: 1
cache_methods:
- GET
- HEAD
cache_min_uses: 1
cache_revalidate: false
cache_use_stale: false
cache_valid:
- code: 200
time: 10m
- code:
- 201
- 202
time: 10m
- time: 1m
connect_timeout: 60s
cookie_domain:
- domain: localhost
replacement: example.com
cookie_flags: false
cookie_path: false
force_ranges: false
headers_hash_bucket_size: 64
headers_hash_max_size: 512
hide_header:
- Date
- X-Accel-Redirect
http_version: 1.1
ignore_client_abort: false
ignore_headers:
- X-Accel-Redirect
intercept_errors: false
limit_rate: 0
max_temp_file_size: 1024m
method: GET
next_upstream:
- error
- timeout
next_upstream_timeout: 0
next_upstream_tries: 0
no_cache:
- $cookie_nocache
- $arg_nocache$arg_comment
pass: http://frontend_servers/
pass_header:
- Date
- X-Accel-Redirect
pass_request_body: false
pass_request_headers: true
read_timeout: 60s
redirect: false
request_buffering: false
send_timeout: 60s
set_body: body
set_header:
- field: Host
value: $proxy_host
- field: Connection
value: close
socket_keepalive: false
ssl_certificate: /etc/ssl/certs/molecule.crt
ssl_certificate_key: /etc/ssl/private/molecule.key
ssl_ciphers:
- DEFAULT
ssl_conf_command: Options PrioritizeChaCha?
ssl_name: $proxy_host
ssl_protocols:
- TLSv1
- TLSv1.1
- TLSv1.2
- TLSv1.3
ssl_server_name: false
ssl_session_reuse: true
ssl_verify: false
ssl_verify_depth: 1
store: false
store_access:
user: rw
group: rw
all: r
temp_file_write_size: 8k
temp_path:
path: /var/cache/nginx/proxy
level: 2
client_max_body_size: 5m
sub_filter:
last_modified: false
once: true
- location: /backend
mirror:
uri: /mirror
proxy_pass: http://backend_servers/
proxy:
set_header:
- field: Host
value: $host
- field: X-Real-IP
value: $remote_addr
- field: X-Forwarded-For
value: $proxy_add_x_forwarded_for
- field: X-Forwarded-Proto
value: $scheme
- location: /mirror
internal: true
proxy:
pass: http://127.0.0.1/
- template_file: http/default.conf.j2
deployment_location: /etc/nginx/conf.d/frontend_default.conf
config:
servers:
- core:
listen:
- port: 8081
server_name: localhost
sub_filter:
sub_filters:
- string: server_hostname
replacement: $hostname
- string: server_address
replacement: $server_addr:$server_port
- string: server_url
replacement: $request_uri
- string: remote_addr
replacement: $remote_addr:$remote_port
- string: server_date
replacement: $time_local
- string: client_browser
replacement: $http_user_agent
- string: request_id
replacement: $request_id
- string: nginx_version
replacement: $nginx_version
- string: document_root
replacement: $document_root
- string: proxied_for_ip
replacement: $http_x_forwarded_for
locations:
- location: /
core:
root: /usr/share/nginx/html
index: frontend_index.html
- location: /api
api:
enable:
write: true
status_zone: two
- template_file: http/default.conf.j2
deployment_location: /etc/nginx/conf.d/backend_default.conf
config:
servers:
- core:
listen:
- port: 8082
server_name: localhost
sub_filter:
sub_filters:
- string: server_hostname
replacement: $hostname
- string: server_address
replacement: $server_addr:$server_port
- string: server_url
replacement: $request_uri
- string: remote_addr
replacement: $remote_addr:$remote_port
- string: server_date
replacement: $time_local
- string: client_browser
replacement: $http_user_agent
- string: request_id
replacement: $request_id
- string: nginx_version
replacement: $nginx_version
- string: document_root
replacement: $document_root
- string: proxied_for_ip
replacement: $http_x_forwarded_for
locations:
- location: /
core:
root: /usr/share/nginx/html
index: backend_index.html
- location: ~ \.php$
core:
root: /usr/share/nginx/html
custom_directives:
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- fastcgi_pass unix:/run/php/php7.2-fpm.sock;
- fastcgi_index index.php;
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
nginx_config_html_demo_template_enable: true
nginx_config_html_demo_template:
- template_file: www/index.html.j2
deployment_location: /usr/share/nginx/html/frontend_index.html
web_server_name: Frontend
- template_file: www/index.html.j2
deployment_location: /usr/share/nginx/html/backend_index.html
web_server_name: Backend
nginx_config_stream_template_enable: true
nginx_config_stream_template:
- template_file: stream/default.conf.j2
deployment_location: /etc/nginx/conf.d/streams/stream_default.conf
config:
upstreams:
- name: stream_upstream
servers:
- address: 0.0.0.0:9091
weight: 1
max_conns: 100
max_fails: 3
fail_timeout: 5s
backup: false
down: false
resolve: false
zone:
name: stream_zone
size: 64k
least_conn: true
core:
preread_buffer_size: 16k
preread_timeout: 30s
proxy_protocol_timeout: 30s
resolver_timeout: 30s
tcp_nodelay: true
variables_hash_bucket_size: 64
variables_hash_max_size: 1024
ssl:
alpn: http/1.1
certificate: /etc/ssl/certs/molecule.crt
certificate_key: /etc/ssl/private/molecule.key
ciphers:
- HIGH
- "!aNull"
- "!MD5"
conf_command: Protocol TLSv1.2
ecdh_curve: auto
handshake_timeout: 60s
prefer_server_ciphers: false
protocols:
- TLSv1
- TLSv1.1
- TLSv1.2
session_cache:
builtin:
enable: true
size: 20480
session_tickets: true
session_timeout: 5m
verify_client: false
verify_depth: 1
proxy:
bind: false
buffer_size: 4k
connect_timeout: 60s
download_rate: 0
half_close: false
next_upstream: true
next_upstream_timeout: 0
next_upstream_tries: 0
protocol: false
requests: 0
responses: 0
session_drop: false
socket_keepalive: false
ssl: false
ssl_certificate: /etc/ssl/certs/molecule.crt
ssl_certificate_key: /etc/ssl/private/molecule.key
ssl_ciphers: HIGH
ssl_conf_command:
- Protocol TLSv1.2
ssl_name: $hostname
ssl_protocols: TLSv1.2
ssl_server_name: false
ssl_session_reuse: true
ssl_verify: false
ssl_verify_depth: 1
timeout: 10m
upload_rate: 0
health_check:
match:
- name: nginx_stream
conditions:
- status 200
timeout: 60s
keyval:
keyvals:
- key: $arg_text
variable: $text
zone: key_stream
zones:
- name: key_stream
size: 10m
state: /var/lib/nginx/state/key.keyval
timeout: 2h
type: string
sync: false
log:
access:
- path: /var/log/nginx/access_stream.log
format: main
buffer: 1m
gzip: 5
flush: 10h
if: $status
format:
- name: main
format: |
'$remote_addr - [$time_local] $status '
error_log:
file: /var/log/nginx/error_stream.log
level: notice
open_log_file_cache:
max: 1000
inactive: 20s
min_uses: 2
valid: 1m
servers:
- core:
listen:
- address: 0.0.0.0
port: 9090
ssl: false
proxy_protocol: false
fastopen: 12
backlog: 511
rcvbuf: 512
sndbuf: 512
bind: false
ipv6only: false
reuseport: false
so_keepalive: false
proxy:
pass: stream_upstream
health_check:
health_checks:
- interval: 5
jitter: 0
fails: 1
passes: 1
uri: /
mandatory: false
persistent: false
match: nginx_stream
udp: true