Repository navigation
Expand file tree
/
Copy pathhaproxy.cfg
More file actions
194 lines (159 loc) · 5.97 KB
/
Copy pathhaproxy.cfg
File metadata and controls
194 lines (159 loc) · 5.97 KB
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
#---------------------------------------------------------------------
# Configuration of HAProxy to front two openshift instances
#
# http://www.haproxy.org/download/2.5/doc/configuration.txt
#
#---------------------------------------------------------------------
global
maxconn 20000
log 127.0.0.1 local0
user haproxy
chroot /usr/share/haproxy
pidfile /run/haproxy.pid
daemon
defaults
timeout connect 5s
timeout client 1m
timeout server 1m
#---------------------------------------------------------------------
# Proxys to the openshift api backend port 6443
#---------------------------------------------------------------------
frontend api_ssl
bind :6443
mode tcp
option tcplog
# Wait for a client hello for at most 5 seconds
tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 }
use_backend home_api_ssl if { req_ssl_sni -i api.home.ocplab.com }
use_backend hub_api_ssl if { req_ssl_sni -i api.hub.ocplab.com }
use_backend microshift_api_ssl if { req_ssl_sni -i api.microshift.ocplab.com }
default_backend static
backend home_api_ssl
mode tcp
balance roundrobin
server home_ssl_server 192.168.1.7:6443 check
backend hub_api_ssl
mode tcp
balance roundrobin
server hub_ssl_server 192.168.1.5:6443 check
backend microshift_api_ssl
mode tcp
balance roundrobin
server microshift_ssl_server 192.168.1.5:6443 check
#---------------------------------------------------------------------
# Proxys to the openshift wildcard backend port 80
#---------------------------------------------------------------------
frontend wildcard_http
bind :80
mode http
use_backend home_http if { hdr(host) -m end .apps.home.ocplab.com }
use_backend hub_http if { hdr(host) -m end .apps.hub.ocplab.com }
use_backend microshift_http if { hdr(host) -m end .apps.microshift.ocplab.com }
default_backend static
backend home_http
mode http
balance roundrobin
server home_http_server 192.168.1.7:80 check
backend hub_http
mode http
balance roundrobin
server hub_http_server 192.168.1.5:80 check
backend microshift_http
mode http
balance roundrobin
server microshift_http_server 192.168.1.5:80 check
#---------------------------------------------------------------------
# Handles port 443 for OpenShift wildcard, sso and terminating SSL for others
#---------------------------------------------------------------------
frontend wildcard_ssl
bind :443
mode tcp
option tcplog
# Wait for a client hello for at most 5 seconds
tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 }
acl internal_ip src 192.168.1.0/24
use_backend home_ssl if { req_ssl_sni -m end .apps.home.ocplab.com }
use_backend hub_ssl if { req_ssl_sni -m end .apps.hub.ocplab.com }
use_backend microshift_ssl if { req_ssl_sni -m end .apps.microshift.ocplab.com }
use_backend sso_ssl if { req_ssl_sni -i sso.ocplab.com }
use_backend cockpit_ssl if { req_ssl_sni -i cockpit.ocplab.com } internal_ip
use_backend gatus_ssl if { req_ssl_sni -i gatus.ocplab.com } internal_ip
# Route back to haproxy to handle SSL termination for non-passthrough sites
default_backend bk_tcp_to_https
# Provide SSL Termination for sites that only handle http
frontend SSL_Termination
mode http
bind *:9443 ssl crt-list /etc/haproxy/crt-list.txt
use_backend jellyfin if { hdr(host) -i jellyfin.ocplab.com }
use_backend homeassistant if { hdr(host) -i homeassistant.ocplab.com }
default_backend homeassistant
#---------------------------------------------------------------------
# Cockpit
#---------------------------------------------------------------------
backend cockpit_ssl
mode tcp
balance roundrobin
server cockpit_ssl_server 192.168.1.2:7070 check
#---------------------------------------------------------------------
# Gatus replacement for uptime-kuma
#---------------------------------------------------------------------
backend gatus_ssl
mode tcp
balance roundrobin
server gatus_ssl_server 192.168.1.2:7443 check
#---------------------------------------------------------------------
# Proxys to the sso server
#---------------------------------------------------------------------
backend sso_ssl
mode tcp
balance roundrobin
server sso_ssl_server 192.168.1.2:8443 check
# Enable haproxy stats page and metrics
frontend stats
mode http
bind *:8404
# option http-use-htx
http-request use-service prometheus-exporter if { path /metrics }
stats enable
stats uri /stats
stats refresh 10s
# Home OpenShift cluster
backend home_ssl
mode tcp
balance roundrobin
server home_ssl_server 192.168.1.7:443 check
# Hub OpenShift cluster
backend hub_ssl
mode tcp
balance roundrobin
server hub_ssl_server 192.168.1.5:443 check
# Microshift cluster
backend microshift_ssl
mode tcp
balance roundrobin
server hub_ssl_server 192.168.1.5:443 check
backend jellyfin
mode http
balance
server jellyfin 192.168.1.2:8096 check
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
backend homeassistant
mode http
balance
server homeassistant 192.168.1.2:8123 check
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
# Route back to haproxy to handle ssl termination
backend bk_tcp_to_https
mode tcp
server haproxy-https 127.0.0.1:9443 check
# Fallback to static site
backend static
mode http
balance roundrobin
timeout connect 5s
timeout server 5s
server static 127.0.0.1:4331 check