
Tengo un nginx de mi cliente donde puedo PUBLICAR exitosamente con:
curl -v --cacert ca.crt --cert client.crt --key client.key -POST https://nginx:8443/api/ -H 'Content-Type: application/json' -H 'cache-control: no-cache' [email protected]
Ahora instalé un haproxy delante de nginx y estoy intentando hacer una POST de la misma manera, sin éxito:
curl -v --cacert ca.crt --cert client.crt --key client.key -POST http://haproxy:8443/api/ -H 'Content-Type: application/json' -H 'cache-control: no-cache' [email protected]
Error:
<center>The plain HTTP request was sent to HTTPS port</center>
<hr><center>nginx</center>
Aquí está mi configuración de haproxy:
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
stats socket /var/lib/haproxy/stats
defaults
mode tcp
log global
option tcplog
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
frontend main *:8443
acl url_static path_beg -i /static /images /javascript /stylesheets
acl url_static path_end -i .jpg .gif .png .css .js
use_backend static if url_static
default_backend app
backend static
balance roundrobin
server static 127.0.0.1:8443
backend app
mode tcp
balance roundrobin
server nginx nginx01:8443
Quiero reenviar el tráfico SSL a través de HAProxy y pasar los certificados de autenticación a nginx. Sé que no tiene ningún sentido tener dos LB pero no puedo modificar nginx y el servidor api detrás, pero los clientes serán internos. Como puede ver en este punto, puedo acceder a nginx pero haproxy no pasa los certificados y claves de la solicitud al backend de nginx. ¿Me estoy perdiendo de algo? ¿Es esto algo que puedo lograr?
PD: Si configuro 'ssl verificar ninguno' en el backend, aparece 'No se envió ningún certificado SSL requerido'. Si configuro 'enviar-proxy' en el backend, obtengo '400 Bad Request' de nginx.
Respuesta1
Deberá agregar la configuración SSL a haproxy y establecer algunos encabezados que se reenviarán al nginx.
# your other config from above
backend app
mode tcp
balance roundrobin
server nginx nginx01:8443 ssl ca-file <The ca from nginx backend>
Respuesta2
la solución implementada fue con paso SS/TLS desdehttps://www.haproxy.com/documentation/haproxy/deployment-guides/tls-infrastructure/ Al configurar tanto el frontend como el backend en modo tcp, pude pasar los certificados y nginx validó e hice la autenticación.