Knowing the server port inside Perl code
Maxim Dounin
mdounin at mdounin.ru
Wed May 2 11:08:43 UTC 2018
Hello!
On Tue, May 01, 2018 at 08:47:15AM +0200, Ondrej Jombik wrote:
> 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?
If you really want to know server port, you can get one by
configuring different auth_http_header in server{} blocks
listening on different ports.
--
Maxim Dounin
http://mdounin.ru/
More information about the nginx
mailing list