Knowing the server port inside Perl code

Ondrej Jombik jombik at
Tue May 1 06:47:15 UTC 2018

When using mail module for SMTP and doing auth using Perl code, it might
be handy to know entry port number. For example 25/TCP, 465/TCP or
587/TCP; those are the most used ones.

I thought this would be somewhere among provided headers:

       [... ...]

However there is nothing like 'Auth-Port', or 'Client-Port' or
'Server-Port' or any port.

'Auth-Protocol' is no help, because we have same protocol running on
multiple ports; typically 25/TCP is the same as 587/TCP when sending
e-mails with auth.

So I tried to help myself:

     proxy on;
     auth_http_header Auth-Port $server_port;
     proxy_pass_error_message on;

- or -

     auth_http_header Auth-Port $proxy_port;

But none of those worked.

How I can know entry port number inside Perl code?

Platon Technologies s.r.o., Hlavna 3, Sala SK-92701
+421222111321 - info at -

Read our latest blog:

My current location: Phoenix, Arizona
My current timezone: -0700 GMT (MST)
(updated automatically)

More information about the nginx mailing list