Knowing the server port inside Perl code

Ondrej Jombik jombik at platon.org
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:

       $request->header_in('Auth-Method');
       $request->header_in('Auth-Protocol');
       $request->header_in('Auth-User');
       $request->header_in('Auth-Pass');
       $request->header_in('Auth-Salt');
       $request->header_in('Client-IP');
       $request->header_in('Client-Host');
       [... ...]

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;
     auth_http 127.0.0.1:80/auth;
     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?

--
Ondrej JOMBIK
Platon Technologies s.r.o., Hlavna 3, Sala SK-92701
+421222111321 - info at platon.net - http://platon.net

Read our latest blog:
https://blog.platon.sk/icann-sknic-tld-problemy/

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



More information about the nginx mailing list