我有以下配置:
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-proxyNGinx:
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和not这两个连接都工作得很好,但在这两种情况下,代理协议头都不会传递到后端
HAProxy:
listen HTTP-TCP_8090
bind :8090
server nginx nginx:8090 send-proxy
listen HTTPS-TCP_8092
bind :8092
server nginx nginx:8092 send-proxyNGinx:
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连接上的代理协议又能将报头传递给后端的配置吗?
发布于 2018-01-12 08:19:38
嗯,看起来NGinx文档不是很好……
https://www.nginx.com/resources/admin-guide/proxy-protocol/
如果希望nginx接受代理协议,则需要在listen指令中添加proxy_protocol参数
listen 8090 proxy_protocol;如果希望nginx发送代理协议,则需要在服务器部分中添加proxy_protocol指令
proxy_protocol on;如果您希望nginx接受代理协议并在其另一端传递accept头,则需要同时添加这两个头!听起来很合理,对吧?正确的。但是它没有很好的文档记录。很容易理解,当处理不是http的流量时,只需在服务器部分中设置proxy_protocol指令,就可以在连接的两端启用它。最后,这是一个有效的配置:
stream {
upstream some_backend {
server some_host:8090;
}
server {
listen 8090 proxy_protocol;
listen 8092 proxy_protocol 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;
}
}https://stackoverflow.com/questions/48211083
复制相似问题