Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to check whether perl cgi request originates from localhost

Tags:

http

cgi

perl

I would like to expose a service written in Perl to localhost HTTP requests. I do not want to modify Apache configuration. How to check whether a Perl CGI HTTP request originates from localhost?

I want for this check to succeed even if this call is made through a virtual host eg. https://www.myserivce.com/hidden/service.pl given that the call is made from inside of www.myserivce.com.

like image 638
agsamek Avatar asked Dec 21 '22 08:12

agsamek


1 Answers

REMOTE_ADDR, but that's a dumb way to do it because you put the authentication logic in the application.

Instead, bind a stand-alone Web server to local interface only, thus the operating system's IP/networking stack guarantees that no request from outside can reach the server.

like image 167
daxim Avatar answered Dec 24 '22 00:12

daxim