<div dir="ltr">for some context, I recently I tried configuring nginx as a tcp proxy that routes<br>connections based on sni to multiple upstream services<div><br>the server only exposes one tcp port, and receives all connections there, for example<br>a connection to <a href="http://redis.example.com:1234">redis.example.com:1234</a> would be proxy_pass'ed to some port in the<br>machine, a connection to <a href="http://www.example.com:1234">www.example.com:1234</a> to another, etc.<br><br>i used nginx itself to terminate the tls for all services for convenience<br><br>the problem:<br>now here is the issue, 1: postgres does some weird custom ssl stuff, which means I<br>cannot terminate the ssl from within nginx, and 2: doing a tcp pass through without<br>the ssl termination, and attempting to use ssl_preread and $ssl_preread_server_name<br>_does not_ work for postgres connections (the module fails to extract the server name)<br><br>what I attempted:<br>what I first thought of was to expand on the ssl_preread module to support postgres<br>connections, I went into the source code and found that the module inserts a handler into<br>the `NGX_STREAM_PREREAD_PHASE`</div><div>I tried looking into the buffer in this phase and no useful data showed up, I then tried to<br>insert a second handler into the `NGX_STREAM_CONTENT_PHASE` and first noticed<br>it is never used or initialised to begin with, so I did that, but then it looks like no buffer<br>is ever available in this phase<br><br>any input, pointers, or suggestions are really welcomed<br><br>thanks<br><br></div></div>