<div>Thank for your reply, Maxim.</div><div> </div><div>What are the chances that you would look into adding these variable into mail module in upstream?</div><div>Looks like it's not very hard to do. Or SNI for mail is not considered to be a real thing?</div><div> </div><div>>> But if the goal is to provide<div>> different certificates to different names requested via SNI in</div><div>> SMTPS and IMAPS connections</div><div> </div><div>I'm afraid I need to support STARTTLS and either completely do AUTH on NGINX or backends.</div><div> </div><div>Also, I wasn't able to find a reason why NGINX intentionally doesn't support passing thru the AUTH to the backend for SMTP, same as with IMAP/POP?</div><div> </div><div>Yeah, I know that SNI for mail protocols is a "grey" area, still want to start implementing it.</div><div> </div><div>Denis</div></div><div> </div><div> </div><div>06.07.2020, 10:32, "Maxim Dounin" <mdounin@mdounin.ru>:</div><div>> Hello!</div><div>></div><div>> On Mon, Jul 06, 2020 at 10:17:31AM -0700, Denis Sh. wrote:</div><div>></div><div>>>  So, when proxying SMTP/IMAP, is it possible to get the Server</div><div>>>  Name that mail clients send as a part of Client Hello?</div><div>></div><div>> Currently no.</div><div>></div><div>>>  Similar to Embedded Variables for ngx_http_ssl_module:</div><div>>>  $ssl_server_name</div><div>>>  returns the server name requested through SNI (1.7.0);</div><div>>></div><div>>>  I don't see these vars defined here https://github.com/nginx/nginx/blob/829c9d5981da1abc81dd7e2fb563da592203e54a/src/mail/ngx_mail_ssl_module.c#L229</div><div>></div><div>> There is no variables in the mail module.</div><div>></div><div>>>  Or should I use `stream` to proxy mail?</div><div>>></div><div>>>  Any ideas?</div><div>></div><div>> This depends on what you are trying to achieve. For obvious</div><div>> reasons stream won't work for complex protocol-dependent things,</div><div>> such as STARTTLS or authentication. But if the goal is to provide</div><div>> different certificates to different names requested via SNI in</div><div>> SMTPS and IMAPS connections, proxying via the stream module with</div><div>> ssl_preread (http://nginx.org/r/ssl_preread) might work for you.</div><div>></div><div>> Note though that in general there is no concept of name-based</div><div>> virtual hosts in mail protocols, and using name-based virtual</div><div>> hosts for SSL might not be a good idea either. Also, status of</div><div>> SNI support by email clients varies, and "unknown" in most cases</div><div>> (https://en.wikipedia.org/wiki/Comparison_of_email_clients).</div><div>></div><div>> --</div><div>> Maxim Dounin</div><div>> http://mdounin.ru/</div><div>> _______________________________________________</div><div>> nginx mailing list</div><div>> nginx@nginx.org</div><div>> http://mailman.nginx.org/mailman/listinfo/nginx</div>