1266d4e1c00f8e910958cdee96ce0da595e37959
[oom.git] / kubernetes / aai / resources / config / haproxy / haproxy-pluggable-security.cfg
1 {{/*
2 # Copyright © 2018 Amdocs, Bell Canada, AT&T
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16 global
17         log /dev/log    local0
18         stats socket /usr/local/etc/haproxy/haproxy.socket mode 660 level admin
19         stats timeout 30s
20         # it is required else pod will not come up
21         maxconn 50000
22         user root
23         group root
24         daemon
25         #################################
26         # Default SSL material locations#
27         #################################
28         ca-base /etc/ssl/certs
29         crt-base /etc/ssl/private
30
31         # Default ciphers to use on SSL-enabled listening sockets.
32         # For more information, see ciphers(1SSL). This list is from:
33         # https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
34         # An alternative list with additional directives can be obtained from
35         # https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
36         tune.ssl.default-dh-param 2048
37
38 defaults
39         log     global
40         mode    http
41         option  httplog
42         option  ssl-hello-chk
43         option  httpchk
44         http-check send meth GET uri /aai/util/echo ver HTTP/1.1 hdr Host aai hdr X-TransactionId  haproxy-0111 hdr X-FromAppId haproxy hdr Accept application/json hdr Authorization 'Basic QUFJOkFBSQ=='
45         default-server init-addr none
46 #       option  dontlognull
47 #       errorfile 400 /etc/haproxy/errors/400.http
48 #       errorfile 403 /etc/haproxy/errors/403.http
49 #       errorfile 408 /etc/haproxy/errors/408.http
50 #       errorfile 500 /etc/haproxy/errors/500.http
51 #       errorfile 502 /etc/haproxy/errors/502.http
52 #       errorfile 503 /etc/haproxy/errors/503.http
53 #       errorfile 504 /etc/haproxy/errors/504.http
54
55         option  http-server-close
56         option forwardfor except 127.0.0.1
57         retries 6
58         option redispatch
59         maxconn 50000
60         timeout connect 50000
61         timeout client  480000
62         timeout server  480000
63         timeout http-keep-alive 30000
64
65 frontend stats
66        bind *:8448
67        http-request use-service prometheus-exporter if { path /metrics }
68        stats enable
69        stats uri /stats
70        stats refresh 10s
71
72 frontend IST_8443
73         mode http
74         bind 0.0.0.0:8443 name https ssl crt /opt/app/osaaf/local/certs/fullchain.pem
75 #       log-format %ci:%cp\ [%t]\ %ft\ %b/%s\ %Tq/%Tw/%Tc/%Tr/%Tt\ %ST\ %B\ %CC\ %CS\ %tsc\ %ac/%fc/%bc/%sc/%rc\ %sq/%bq\ %hr\ %hs\ {%[ssl_c_verify],%{+Q}[ssl_c_s_dn],%{+Q}[ssl_c_i_dn]}\ %{+Q}r
76         log-format "%ci:%cp [%tr] %ft %b/%s %TR/%Tw/%Tc/%Tr/%Ta %ST %B %CC \ %CS %tsc %ac/%fc/%bc/%sc/%rc %sq/%bq %hr %hs %{+Q}r"
77         option httplog
78         log global
79         option logasap
80         option forwardfor
81         capture request header  Host len 100
82         capture response header Host len 100
83         option log-separate-errors
84         option forwardfor
85
86         http-request set-header X-Forwarded-Proto https
87         http-request add-header X-Forwarded-Port 8443
88
89         http-request set-header X-Forwarded-Proto https if { ssl_fc }
90         http-request set-header X-AAI-Client-SSL TRUE if { ssl_c_used }
91         http-request set-header X-AAI-SSL                       %[ssl_fc]
92         http-request set-header X-AAI-SSL-Client-Verify         %[ssl_c_verify]
93         http-request set-header X-AAI-SSL-Client-DN             %{+Q}[ssl_c_s_dn]
94         http-request set-header X-AAI-SSL-Client-CN             %{+Q}[ssl_c_s_dn(cn)]
95         http-request set-header X-AAI-SSL-Issuer                %{+Q}[ssl_c_i_dn]
96         http-request set-header X-AAI-SSL-Client-NotBefore      %{+Q}[ssl_c_notbefore]
97         http-request set-header X-AAI-SSL-Client-NotAfter       %{+Q}[ssl_c_notafter]
98         http-request set-header X-AAI-SSL-ClientCert-Base64   %{+Q}[ssl_c_der,base64]
99         http-request set-header X-AAI-SSL-Client-OU             %{+Q}[ssl_c_s_dn(OU)]
100         http-request set-header X-AAI-SSL-Client-L              %{+Q}[ssl_c_s_dn(L)]
101         http-request set-header X-AAI-SSL-Client-ST             %{+Q}[ssl_c_s_dn(ST)]
102         http-request set-header X-AAI-SSL-Client-C              %{+Q}[ssl_c_s_dn(C)]
103         http-request set-header X-AAI-SSL-Client-O              %{+Q}[ssl_c_s_dn(O)]
104 #######################################
105 ## Request blocking configuration ###
106 #######################################
107         {{- if eq $.Values.haproxy.requestBlocking.enabled true }}
108         {{- range $custom_config := $.Values.haproxy.requestBlocking.customConfigs }}
109         {{ $custom_config }}
110         {{- end }}
111         {{- end }}
112
113 #######################
114 #ACLS FOR PORT 8446####
115 #######################
116
117         acl is_Port_8446_generic path_reg -i ^/aai/v[0-9]+/search/generic-query$
118         acl is_Port_8446_nodes path_reg -i ^/aai/v[0-9]+/search/nodes-query$
119         acl is_Port_8446_version path_reg -i ^/aai/v[0-9]+/query$
120         acl is_dsl path_reg -i ^/aai/v[0-9]+/dsl$
121         acl is_named-query path_beg -i /aai/search/named-query
122         acl is_search-model path_beg -i /aai/search/model
123         use_backend IST_AAI_8446 if is_Port_8446_generic or is_Port_8446_nodes or is_Port_8446_version or is_named-query or is_search-model or is_dsl
124
125         default_backend IST_Default_8447
126
127
128 #######################
129 #DEFAULT BACKEND 8447##
130 #######################
131
132 backend IST_Default_8447
133         balance roundrobin
134         stick-table type string len 100 size 200k expire 2m
135         stick on path
136         http-request set-header X-Forwarded-Port %[src_port]
137         http-response set-header Strict-Transport-Security max-age=16000000;\ includeSubDomains;\ preload;
138         server-template aai-resources.{{.Release.Namespace}} {{$.Values.haproxy.replicas.aaiResources}} aai-resources.{{.Release.Namespace}}.svc.cluster.local:8447 resolvers kubernetes check check-ssl port 8447 ssl verify none
139
140
141 #######################
142 # BACKEND 8446#########
143 #######################
144
145 backend IST_AAI_8446
146         balance roundrobin
147         stick-table type string len 100 size 200k expire 2m
148         stick on path
149         http-request set-header X-Forwarded-Port %[src_port]
150         http-response set-header Strict-Transport-Security max-age=16000000;\ includeSubDomains;\ preload;
151         server-template aai-traversal.{{.Release.Namespace}} {{$.Values.haproxy.replicas.aaiTraversal}} aai-traversal.{{.Release.Namespace}}.svc.cluster.local:8446 resolvers kubernetes check check-ssl port 8446 ssl verify none
152
153 listen IST_AAI_STATS
154         mode http
155         bind *:8080
156         stats uri /stats
157         stats enable
158         stats refresh 30s
159         stats hide-version
160         stats auth admin:admin
161         stats show-legends
162         stats show-desc IST AAI APPLICATION NODES
163         stats admin if TRUE