Merge pull request #25 from byjg/fix-ssl
Fix-ssl error when no letsencrypt
This commit is contained in:
commit
e20f241ab4
15 changed files with 99 additions and 45 deletions
|
|
@ -180,6 +180,12 @@ stats:
|
||||||
|
|
||||||
customerrors: true # Optional (default false)
|
customerrors: true # Optional (default false)
|
||||||
|
|
||||||
|
ssl_mode: default
|
||||||
|
|
||||||
|
letsencrypt: {
|
||||||
|
"email": "acme@example.org"
|
||||||
|
}
|
||||||
|
|
||||||
easymapping:
|
easymapping:
|
||||||
- port: 80
|
- port: 80
|
||||||
hosts:
|
hosts:
|
||||||
|
|
@ -191,17 +197,16 @@ easymapping:
|
||||||
host2.com.br:
|
host2.com.br:
|
||||||
containers:
|
containers:
|
||||||
- other:3000
|
- other:3000
|
||||||
ssl: false
|
|
||||||
redirect:
|
redirect:
|
||||||
www.host1.com.br: http://host1.com.br
|
www.host1.com.br: http://host1.com.br
|
||||||
|
|
||||||
- port: 443
|
- port: 443
|
||||||
ssl_cert: /path/to/ssl/certificate
|
|
||||||
hosts:
|
hosts:
|
||||||
host1.com.br:
|
host1.com.br:
|
||||||
containers:
|
containers:
|
||||||
- container:80
|
- container:80
|
||||||
redirect-ssl: false
|
redirect-ssl: false
|
||||||
|
ssl: true
|
||||||
|
|
||||||
- port: 8080
|
- port: 8080
|
||||||
hosts:
|
hosts:
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
# Simple file include
|
|
||||||
|
|
@ -44,13 +44,11 @@ if cmp -s ${CONTROL_FILE} ${CONTROL_FILE}.old ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -z "$1" ]]; then
|
if [[ ! -z "$1" ]]; then
|
||||||
echo "[CONF_CHECK] Initial configuration"
|
echo "[CONF_CHECK] Initial configuration. Skip certbot."
|
||||||
RELOAD="false"
|
|
||||||
else
|
else
|
||||||
/scripts/certbot.sh
|
/scripts/certbot.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# If Certbot reloads successfully will create the file /tmp/force-reload
|
# If Certbot reloads successfully will create the file /tmp/force-reload
|
||||||
if [ -f /tmp/force-reload ]; then
|
if [ -f /tmp/force-reload ]; then
|
||||||
echo "[CONF_CHECK] New certificates found..."
|
echo "[CONF_CHECK] New certificates found..."
|
||||||
|
|
@ -58,7 +56,12 @@ if [ -f /tmp/force-reload ]; then
|
||||||
rm /tmp/force-reload
|
rm /tmp/force-reload
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -z "$1" ]]; then
|
||||||
|
echo "[CONF_CHECK] Start haproxy"
|
||||||
|
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$RELOAD" == "true" ]]; then
|
if [[ "$RELOAD" == "true" ]]; then
|
||||||
echo "[CONF_CHECK] Reloading..."
|
echo "[CONF_CHECK] Reloading..."
|
||||||
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -x /var/run/haproxy.sock -sf $(cat /run/haproxy.pid) &
|
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg $(ls /etc/haproxy/conf.d/*.cfg 2>/dev/null | xargs -I{} echo -f {}) -p /run/haproxy.pid -x /var/run/haproxy.sock -sf $(cat /run/haproxy.pid) &
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
source /scripts/haproxy-reload.sh initial
|
/usr/sbin/haproxy -v
|
||||||
|
|
||||||
/usr/sbin/haproxy -W -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /var/run/haproxy.sock
|
source /scripts/haproxy-reload.sh initial
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
sleep 60
|
sleep 60
|
||||||
|
|
|
||||||
|
|
@ -165,7 +165,7 @@ class HaproxyConfigGenerator:
|
||||||
easymapping["443"]["hosts"][hostname] = dict(easymapping[port]["hosts"][hostname])
|
easymapping["443"]["hosts"][hostname] = dict(easymapping[port]["hosts"][hostname])
|
||||||
easymapping["443"]["hosts"][hostname]["letsencrypt"] = False
|
easymapping["443"]["hosts"][hostname]["letsencrypt"] = False
|
||||||
easymapping["443"]["hosts"][hostname]["redirect_ssl"] = False
|
easymapping["443"]["hosts"][hostname]["redirect_ssl"] = False
|
||||||
easymapping["443"]["ssl_cert"] = self.ssl_cert_letsecncrypt
|
easymapping["443"]["ssl"] = True
|
||||||
self.letsencrypt_hosts.append(hostname) if hostname not in self.letsencrypt_hosts else self.letsencrypt_hosts
|
self.letsencrypt_hosts.append(hostname) if hostname not in self.letsencrypt_hosts else self.letsencrypt_hosts
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -175,12 +175,12 @@ class HaproxyConfigGenerator:
|
||||||
filename = "{}/{}.pem".format(
|
filename = "{}/{}.pem".format(
|
||||||
self.ssl_cert_haproxy, d[host_label]
|
self.ssl_cert_haproxy, d[host_label]
|
||||||
)
|
)
|
||||||
easymapping[port]["ssl_cert"] = filename
|
easymapping[port]["ssl"] = True
|
||||||
with open(filename, 'wb') as file:
|
with open(filename, 'wb') as file:
|
||||||
file.write(
|
file.write(
|
||||||
base64.b64decode(d[ssl_label])
|
base64.b64decode(d[ssl_label])
|
||||||
)
|
)
|
||||||
if self.label.get_bool(self.label.create([definition, "ssl"])):
|
if self.label.get_bool(self.label.create([definition, "ssl"])):
|
||||||
easymapping[port]["ssl_cert"] = self.ssl_cert_haproxy
|
easymapping[port]["ssl"] = True
|
||||||
|
|
||||||
return easymapping.values()
|
return easymapping.values()
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,9 @@
|
||||||
# location: https://host1.local/
|
# location: https://host1.local/
|
||||||
#
|
#
|
||||||
# curl -I -H Host:host2.local http://127.0.0.1
|
# curl -I -H Host:host2.local http://127.0.0.1
|
||||||
# HTTP/1.1 200 OK
|
# HTTP/1.1 301 Moved Permanently
|
||||||
# accept-ranges: bytes
|
# content-length: 0
|
||||||
# content-length: 3276
|
# location: https://host1.local/
|
||||||
# content-type: text/html; charset=utf-8
|
|
||||||
# last-modified: Tue, 16 Aug 2022 15:48:05 GMT
|
|
||||||
# date: Tue, 16 Aug 2022 16:36:35 GMT
|
|
||||||
#
|
#
|
||||||
# Test SSL:
|
# Test SSL:
|
||||||
# openssl s_client -showcerts -connect 127.0.0.1:443 --servername host1.local
|
# openssl s_client -showcerts -connect 127.0.0.1:443 --servername host1.local
|
||||||
|
|
@ -25,6 +22,7 @@ services:
|
||||||
image: byjg/easy-haproxy
|
image: byjg/easy-haproxy
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
- ./host2.local.pem:/certs/haproxy/host2.local.pem
|
||||||
environment:
|
environment:
|
||||||
EASYHAPROXY_DISCOVER: docker
|
EASYHAPROXY_DISCOVER: docker
|
||||||
EASYHAPROXY_SSL_MODE: "loose"
|
EASYHAPROXY_SSL_MODE: "loose"
|
||||||
|
|
@ -54,11 +52,11 @@ services:
|
||||||
image: byjg/static-httpserver
|
image: byjg/static-httpserver
|
||||||
labels:
|
labels:
|
||||||
easyhaproxy.http.host: host2.local
|
easyhaproxy.http.host: host2.local
|
||||||
easyhaproxy.http.localport: 8080
|
|
||||||
easyhaproxy.http.port: 80
|
easyhaproxy.http.port: 80
|
||||||
|
easyhaproxy.http.redirect_ssl: true
|
||||||
|
|
||||||
easyhaproxy.https.port: 443
|
easyhaproxy.https.port: 443
|
||||||
easyhaproxy.https.localport: 8080
|
easyhaproxy.https.localport: 8080
|
||||||
easyhaproxy.https.host: host2.local
|
easyhaproxy.https.host: host2.local
|
||||||
easyhaproxy.https.sslcert: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURxVENDQXBHZ0F3SUJBZ0lVSWQ1Yjl0OXVxSDc4ZzAyRXpiV0Y2RktWdzNnd0RR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dDZVbzhDZ1lCWDdORFVsaTFTbG9IMVhsc3ZEMDQ3UzhGSGFNN3lsOTk0RjNKMFVtRGZwc3pjajFQNAo5cEY2NE1tcTQvM1l0MGxpMG1NdVRiL0pnYjN4cllnRkpYa2NlY0thaEVWSDNyb3B1cCt1bXNMQUFJaXJVTVFxClZTa0Z3SjBRdG5qL2RlRFV3UE51YU9YOGNkNjVPNUNGVjZ6SVI5eEJFREQ4ZkJzUDJaTE96bWVmRFFLQmdRREYKbTI0dlZ0aGQvMWNKZENnRCswVnhOWVhESGVJVlhMRm8xUzBpTFlDTkxuM3RqWmxSUUJLVVh6WkplM2F5MC9yZgpzTk5EN2FTWUhNWWtUenlkREpiYzFQb056eG15RFVpVFhwT1dxeVVFeE0vZmJCMVZVUEU1aDQ3QXhxZFoyb0dOCkV0ZGdqcE1aTG1DSUMyU2tHc0wrM05Kb2s4VUtIZHB1RXJtbVFJTWs1UUtCZ1FDZ0VXY1l0TFhDM1lEWU1GZEkKVWdjVGViRnFTczNtTFlndWIxeGVrVzNJWFIyeW9tNFY1ZlFUTGlGN1lmbjJkcERXNEljTVUwVUpGWVZzVWxoSwphR3RldDRWbTVObjgrTWdob3Q1eUFqcU85eUFVYXViN3dnaWZLSWU5OXRRS2Q4dVp5Q3ZKMGhodm1ERFNmeDRtCkIvVEVpRkFPOTl5RjQ5aVN4RVZTQVM2cHFRPT0KLS0tLS1FTkQgUFJJVkFURSBLRVktLS0tLQo=
|
easyhaproxy.https.ssl: true
|
||||||
|
|
||||||
|
|
|
||||||
50
examples/docker/host2.local.pem
Normal file
50
examples/docker/host2.local.pem
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
-----BEGIN CERTIFICATE-----
|
||||||
|
MIIDqTCCApGgAwIBAgIUId5b9t9uqH78g02EzbWF6FKVw3gwDQYJKoZIhvcNAQEL
|
||||||
|
BQAwZDELMAkGA1UEBhMCQlIxFzAVBgNVBAgMDlJpbyBkZSBKYW5laXJvMRcwFQYD
|
||||||
|
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Y5mizXklDyDNuG5U0
|
||||||
|
lXv9egMGBsy0dG6eFXkU5CPdxWU540yI2sCtSAj7z+WRUD5k7gJ7tVoY3//jHQZG
|
||||||
|
5STTmm5t9kpIZTWkptyJos9oZJFYMIXqW2Fc6tyLZpRp31R78tDs6ETIkToDc0RR
|
||||||
|
jz66th6HI+ZlgIBQhw09+hYAhBDe9+Dmd/SzQZc=
|
||||||
|
-----END CERTIFICATE-----
|
||||||
|
-----BEGIN PRIVATE KEY-----
|
||||||
|
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDEir6zmoWrwl57
|
||||||
|
0hedd9YaaOpOuQue44EUPOBWg4+TGyTlZWEFRbTBtFzpO2voYeb9X3uMB9EeyOhQ
|
||||||
|
6NFfbEvrLJKOW7BJXNcWJYOR27iqvPb0UioOhA5c7cdwSm4vddj5rebxRjSdes3M
|
||||||
|
O+w1K0CF6OCP2+Gt6ZgYlo+NzaEyK5klh7bBsMDo94g70sHqnWFySK94aRx+buqa
|
||||||
|
IYw6EL6g8yujLvKepoQlCjbOyhSZzSJzRtuaEE+jtJ+DhrZoEYy1qKXRJzoTJCrH
|
||||||
|
yKCNV7ZVwSwQ7+4biApN7ecsLXwkMjtPZF+5RSIHea5+/jI8B+VjXqm0Ccbmqo6F
|
||||||
|
0JzWVIFLAgMBAAECggEBAKceitVROQQ5e/mxRR9CfK1sNH/H3Ne3/1PkB6XIrFab
|
||||||
|
qB3evEatZOuon7A6NKEeTjl37Se+pdSVZOUXcqC/BzbraZre3+EhrkpIj72ApV+Y
|
||||||
|
2iwZiWVaaJQgI4uZ3mNAw8RaWJsj5S1a9I8LDOiQ5IZ45CmvABDPJeMScvJSvRRY
|
||||||
|
e5N0L6stqS7Z+IoyGVKUfp1iNO0YyywOUiSkIRXgscuRXZGYpiGPomsJ+Js1ejzW
|
||||||
|
jyStlZJEr4L1285rGPrmHqjTwFd+hG80Wc4179xL+WRE6HBEUZSiy95fe6kcPHXX
|
||||||
|
BgiVYtcFKmiBi2dTbxl4e94ut239i0HtlJ1ZJtLh+BECgYEA8a298K2zXkHosxhN
|
||||||
|
tRrH7XfMPTkHDDd3rxM21LT+fIXqinGUp9LYaDcbjuTPs8e33uKMd7R6Q40x89yW
|
||||||
|
IXNka/VL0PXUeV67aCVLLqgXDLGudluJinH0XvmI0CmBecFSMqIFmQlgqERoGGs3
|
||||||
|
UMac0p876T4XkGQQJdf62bFpE4UCgYEA0DBH0PDlOpwXccDgXrMfayr8HAhI+G5R
|
||||||
|
yWQ//9iirtU83chwIWwkh53eLLMzLgdqJnPiWyaUW5BqzmYuD23nhxcQ7PNdIqOO
|
||||||
|
H1sE6zqLNshv46t5QKlh1Q4qjd7UqtgrSrY63RXJCMWTwnNMeDLtj8gaKbjkrG3R
|
||||||
|
BM2ildt6Uo8CgYBX7NDUli1SloH1XlsvD047S8FHaM7yl994F3J0UmDfpszcj1P4
|
||||||
|
9pF64Mmq4/3Yt0li0mMuTb/Jgb3xrYgFJXkcecKahEVH3ropup+umsLAAIirUMQq
|
||||||
|
VSkFwJ0Qtnj/deDUwPNuaOX8cd65O5CFV6zIR9xBEDD8fBsP2ZLOzmefDQKBgQDF
|
||||||
|
m24vVthd/1cJdCgD+0VxNYXDHeIVXLFo1S0iLYCNLn3tjZlRQBKUXzZJe3ay0/rf
|
||||||
|
sNND7aSYHMYkTzydDJbc1PoNzxmyDUiTXpOWqyUExM/fbB1VUPE5h47AxqdZ2oGN
|
||||||
|
EtdgjpMZLmCIC2SkGsL+3NJok8UKHdpuErmmQIMk5QKBgQCgEWcYtLXC3YDYMFdI
|
||||||
|
UgcTebFqSs3mLYgub1xekW3IXR2yom4V5fQTLiF7Yfn2dpDW4IcMU0UJFYVsUlhK
|
||||||
|
aGtet4Vm5Nn8+Mghot5yAjqO9yAUaub7wgifKIe99tQKd8uZyCvJ0hhvmDDSfx4m
|
||||||
|
B/TEiFAO99yF49iSxEVSAS6pqQ==
|
||||||
|
-----END PRIVATE KEY-----
|
||||||
|
|
@ -12,7 +12,7 @@ easymapping:
|
||||||
www.host1.local: https://host1.local
|
www.host1.local: https://host1.local
|
||||||
|
|
||||||
- port: 443
|
- port: 443
|
||||||
ssl_cert: /certs/haproxy/host1.local.pem
|
ssl: true
|
||||||
hosts:
|
hosts:
|
||||||
host1.local:
|
host1.local:
|
||||||
containers:
|
containers:
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ services:
|
||||||
image: byjg/easy-haproxy
|
image: byjg/easy-haproxy
|
||||||
volumes:
|
volumes:
|
||||||
- ./config.yml:/etc/haproxy/easyconfig.yml
|
- ./config.yml:/etc/haproxy/easyconfig.yml
|
||||||
- ./certs:/certs
|
- ./host1.local.pem:/certs/haproxy/host1.local.pem
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
environment:
|
environment:
|
||||||
EASYHAPROXY_DISCOVER: static
|
EASYHAPROXY_DISCOVER: static
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
{% if "ssl_cert" in o %}
|
{% if "ssl" in o %}
|
||||||
bind *:{{ o["port"] }} ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
bind *:{{ o["port"] }} ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||||
{% elif "h2" in o and o["h2"] %}
|
{% elif "h2" in o and o["h2"] %}
|
||||||
bind *:{{ o["port"] }} proto h2
|
bind *:{{ o["port"] }} proto h2
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
use_backend letsencrypt_backend if is_letsencrypt_{{ host }} is_rule_{{ host }}_1 OR is_letsencrypt_{{ host }} is_rule_{{ host }}_2
|
use_backend letsencrypt_backend if is_letsencrypt_{{ host }} is_rule_{{ host }}_1 OR is_letsencrypt_{{ host }} is_rule_{{ host }}_2
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if o["hosts"][k]["redirect_ssl"] %}
|
{% if o["hosts"][k]["redirect_ssl"] %}
|
||||||
http-request redirect scheme https code 301 if !is_letsencrypt_{{ host }} is_rule_{{ host }}_1 OR !is_letsencrypt_{{ host }} is_rule_{{ host }}_2
|
http-request redirect scheme https code 301 if {% if letsencrypt %}!is_letsencrypt_{{ host }} {% endif %}is_rule_{{ host }}_1 OR {% if letsencrypt %}!is_letsencrypt_{{ host }} {% endif %}is_rule_{{ host }}_2
|
||||||
{% else %}
|
{% else %}
|
||||||
use_backend srv_{{ host }} if is_rule_{{ host }}_1 OR is_rule_{{ host }}_2
|
use_backend srv_{{ host }} if is_rule_{{ host }}_1 OR is_rule_{{ host }}_2
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,16 @@
|
||||||
global
|
global
|
||||||
log stdout format raw local0 info
|
log stdout format raw local0 info
|
||||||
maxconn 2000
|
maxconn 2000
|
||||||
tune.ssl.default-dh-param 2048
|
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA
|
||||||
|
|
||||||
# intermediate configuration
|
|
||||||
ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
|
|
||||||
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
|
ssl-default-bind-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
|
||||||
ssl-default-bind-options prefer-client-ciphers no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets
|
ssl-default-bind-options no-sslv3 no-tls-tickets
|
||||||
|
|
||||||
ssl-default-server-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
|
ssl-default-server-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA
|
||||||
ssl-default-server-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
|
ssl-default-server-ciphersuites TLS_AES_128_GCM_SHA256:TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256
|
||||||
ssl-default-server-options no-sslv3 no-tlsv10 no-tlsv11 no-tls-tickets
|
ssl-default-server-options no-sslv3 no-tls-tickets
|
||||||
|
|
||||||
|
ssl-dh-param-file /etc/haproxy/dhparam-1024
|
||||||
|
|
||||||
ssl-dh-param-file /etc/haproxy/dhparam
|
|
||||||
|
|
||||||
defaults
|
defaults
|
||||||
log global
|
log global
|
||||||
|
|
@ -28,11 +26,11 @@ frontend http_in_80
|
||||||
|
|
||||||
acl is_rule_host2_local_80_1 hdr(host) -i host2.local
|
acl is_rule_host2_local_80_1 hdr(host) -i host2.local
|
||||||
acl is_rule_host2_local_80_2 hdr(host) -i host2.local:80
|
acl is_rule_host2_local_80_2 hdr(host) -i host2.local:80
|
||||||
use_backend srv_host2_local_80 if is_rule_host2_local_80_1 OR is_rule_host2_local_80_2
|
http-request redirect scheme https code 301 if is_rule_host2_local_80_1 OR is_rule_host2_local_80_2
|
||||||
|
|
||||||
acl is_rule_host1_local_80_1 hdr(host) -i host1.local
|
acl is_rule_host1_local_80_1 hdr(host) -i host1.local
|
||||||
acl is_rule_host1_local_80_2 hdr(host) -i host1.local:80
|
acl is_rule_host1_local_80_2 hdr(host) -i host1.local:80
|
||||||
http-request redirect scheme https code 301 if !is_letsencrypt_host1_local_80 is_rule_host1_local_80_1 OR !is_letsencrypt_host1_local_80 is_rule_host1_local_80_2
|
http-request redirect scheme https code 301 if is_rule_host1_local_80_1 OR is_rule_host1_local_80_2
|
||||||
|
|
||||||
backend srv_host2_local_80
|
backend srv_host2_local_80
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
|
|
@ -40,14 +38,14 @@ backend srv_host2_local_80
|
||||||
option forwardfor
|
option forwardfor
|
||||||
http-request set-header X-Forwarded-Port %[dst_port]
|
http-request set-header X-Forwarded-Port %[dst_port]
|
||||||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||||
server srv-0 b18a88da403b:8080 check weight 1
|
server srv-0 3571640c480a:80 check weight 1
|
||||||
backend srv_host1_local_80
|
backend srv_host1_local_80
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
mode http
|
mode http
|
||||||
option forwardfor
|
option forwardfor
|
||||||
http-request set-header X-Forwarded-Port %[dst_port]
|
http-request set-header X-Forwarded-Port %[dst_port]
|
||||||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||||
server srv-0 78a90f5c2d8a:80 check weight 1
|
server srv-0 5b69bc7fea1b:80 check weight 1
|
||||||
|
|
||||||
frontend http_in_443
|
frontend http_in_443
|
||||||
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
bind *:443 ssl crt /certs/letsencrypt/ alpn http/1.1 crt /certs/haproxy/ alpn http/1.1
|
||||||
|
|
@ -67,14 +65,14 @@ backend srv_host2_local_443
|
||||||
option forwardfor
|
option forwardfor
|
||||||
http-request set-header X-Forwarded-Port %[dst_port]
|
http-request set-header X-Forwarded-Port %[dst_port]
|
||||||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||||
server srv-0 b18a88da403b:8080 check weight 1
|
server srv-0 3571640c480a:8080 check weight 1
|
||||||
backend srv_host1_local_443
|
backend srv_host1_local_443
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
mode http
|
mode http
|
||||||
option forwardfor
|
option forwardfor
|
||||||
http-request set-header X-Forwarded-Port %[dst_port]
|
http-request set-header X-Forwarded-Port %[dst_port]
|
||||||
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
http-request add-header X-Forwarded-Proto https if { ssl_fc }
|
||||||
server srv-0 78a90f5c2d8a:8080 check weight 1
|
server srv-0 5b69bc7fea1b:8080 check weight 1
|
||||||
|
|
||||||
backend letsencrypt_backend
|
backend letsencrypt_backend
|
||||||
mode http
|
mode http
|
||||||
|
|
|
||||||
6
tests/fixtures/services-redirect-ssl
vendored
6
tests/fixtures/services-redirect-ssl
vendored
File diff suppressed because one or more lines are too long
2
tests/fixtures/static.yml
vendored
2
tests/fixtures/static.yml
vendored
|
|
@ -19,7 +19,7 @@ easymapping:
|
||||||
www.host1.com.br: http://host1.com.br
|
www.host1.com.br: http://host1.com.br
|
||||||
|
|
||||||
- port: 443
|
- port: 443
|
||||||
ssl_cert: /certs/haproxy/mycert.pem
|
ssl: True
|
||||||
hosts:
|
hosts:
|
||||||
host1.com.br:
|
host1.com.br:
|
||||||
containers:
|
containers:
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ def test_parser_finds_services_raw():
|
||||||
"byjg.ca":"https://www.somehost.com.br",
|
"byjg.ca":"https://www.somehost.com.br",
|
||||||
"www.byjg.ca":"https://www.somehost.com.br"
|
"www.byjg.ca":"https://www.somehost.com.br"
|
||||||
},
|
},
|
||||||
"ssl_cert":CERT_FILE
|
"ssl": True
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"mode":"http",
|
"mode":"http",
|
||||||
|
|
@ -247,7 +247,7 @@ def test_parser_static_raw():
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"port": 443,
|
"port": 443,
|
||||||
"ssl_cert": "/certs/haproxy/mycert.pem",
|
"ssl": True,
|
||||||
"hosts": {
|
"hosts": {
|
||||||
"host1.com.br": {
|
"host1.com.br": {
|
||||||
"containers": [
|
"containers": [
|
||||||
|
|
@ -333,7 +333,8 @@ def test_parser_redirect_ssl():
|
||||||
line_list = load_fixture("services-redirect-ssl")
|
line_list = load_fixture("services-redirect-ssl")
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
"customerrors": False
|
"customerrors": False,
|
||||||
|
"ssl_mode": "loose"
|
||||||
}
|
}
|
||||||
|
|
||||||
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
cfg = easymapping.HaproxyConfigGenerator(result, CERTS_FOLDER)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue