Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我做了一个项目,只能限制来自内部服务器的请求(在那些机器上)。
有没有办法使用php检查来自内部服务器的请求?
诸如 cron 作业之类的东西,只有在内部服务器请求时才能执行。如果来自外部站点的任何请求,请忽略它。
您可以通过这种方式实现此目的
if($_SERVER['REMOTE_ADDR'] != $_SERVER['SERVER_ADDR'] || $_SERVER['REMOTE_ADDR'] != '127.0.0.1') die('Only internal requests are allowed');