我有以下配置:
HAProxy -> NGinx -> 后端
(HAProxy用于负载均衡,NGinx用于SSL终止)配置不可更改
我正在尝试使用代理协议将源 IP 传递给后端。在没有 SSL 的情况下工作一切正常。将 SSL 添加到等式中我要么在 SSL 握手时失败,要么我看不到让 NGinx 将代理协议传递到后端的方法。
示例配置1:
代理协议在非 ssl 连接上很好地传递,但对于 ssl 连接,ssl 握手中断
HAProxy:
listen HTTP-TCP_8090
bind :8090
server nginx nginx:8090 send-proxy
listen HTTPS-TCP_8092
bind :8092
server nginx nginx:8092 send-proxy
NGinx:
stream {
upstream some_backend {
server some_host:8090;
}
server {
listen 8090;
listen 8092 ssl;
proxy_pass some_backend;
proxy_protocol on;
ssl_certificate /etc/ssl/server.crt;
ssl_certificate_key /etc/ssl/server.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSLTCP:20m;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
}
}
示例配置2:
两个连接(无论是 ssl 还是非 ssl)都运行良好,但代理协议标头在这两种情况下都没有传递到后端
HAProxy:
listen HTTP-TCP_8090
bind :8090
server nginx nginx:8090 send-proxy
listen HTTPS-TCP_8092
bind :8092
server nginx nginx:8092 send-proxy
NGinx:
stream {
upstream some_backend {
server some_host:8090;
}
server {
listen 8090 proxy_protocol;
listen 8092 proxy_protocol ssl;
proxy_pass some_backend;
ssl_certificate /etc/ssl/server.crt;
ssl_certificate_key /etc/ssl/server.key;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_session_cache shared:SSLTCP:20m;
ssl_session_timeout 4h;
ssl_handshake_timeout 30s;
}
}
知道如何创建一个配置,它既可以识别 SSL 连接上的代理协议,又可以将标头传递给后端?