只有从本地主机接受GET / POST请求

编程入门 行业动态 更新时间:2024-10-28 16:25:05
本文介绍了只有从本地主机接受GET / POST请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

由于数据的大小是不小的,我的web应用程序需要加载,它得到pretty的速度慢了一些时间,以便为此,我决定添加一些jQuery的AJAX功能要求加载某些数据,然后将其保存在一个缓存。

Because the data size isn't little that my web app needs to load, it gets pretty slow some times so therefor I decided to add some jQuery ajax functions to load certain data upon request and then save it in a cache.

我想知道的是,我怎么能限制任何 GET 或 POST 请求只能从本地主机/同服务器/同一个IP,所以我可以避免外界任何调用我的应用程序?

What I would like to know is how can I limit any GET or POST requests only from localhost/same server/same ip so I can avoid any calls from outside to my app?

这意味着,我的PHP函数返回的数据,只要从本地主机请求应该返回的数据。

That means that my php functions that returns data, should return data only if requested from localhost.

我的Web应用程序运行于codeIgniter的框架和我的Web服务器的配置运行在Ubuntu上的灯。

My web app runs on CodeIgniter's framework and my web server's configuration is a LAMP running on ubuntu.

任何想法?

推荐答案

在构造函数中,你可以使用

in the constructor you could use

if ($_SERVER['SERVER_ADDR'] != $_SERVER['REMOTE_ADDR']){ $this->output->set_status_header(400, 'No Remote Access Allowed'); exit; //just for good measure }

然而,如果这种方法心不是你要找的内容。使用的.htaccess 则可以执行快速谷歌搜索返回一个具体的例子否认GET / POST来所有然后允许127.0.0.1/localhost。

However if this method isnt what you're looking for.. use .htaccess you can perform a quick google search to return a specific example for denying get/post to all and then allow for 127.0.0.1/localhost.

更多推荐

只有从本地主机接受GET / POST请求

本文发布于:2023-10-12 00:31:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1483273.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:主机   POST

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!