Iptables url 过滤

Iptables url 过滤

我有一个网络应用程序,我想像这样过滤访问:阻止到 http://my-ip:8080/ 的传入连接,访问传入/传出到 http://my-ip:8080/the-rest-of-the-address,实际上我想阻止对我的网络服务器的访问,但不阻止应用程序,这不起作用并将其全部放弃。

sbin/iptables -I INPUT -p tcp –dport 80 -m string –string “Host: http://my-ip:8080/” –algo kmp -j DROP

谁能帮我?

答案1

根据您使用的 Web 服务器,如果您想要限制对某些文件夹的访问并且您正在使用 Apache,.htaccess 文件可能会对您有所帮助。在文档根目录中,您可以创建一个允许任何访问尝试的 .htaccess。

(参见这个问题:https://stackoverflow.com/questions/17867576/deny-access-to-all-folders-except-a-few-ones-using-htaccess

答案2

尝试这个:

sbin/iptables -I INPUT -p tcp –dport 8080 -m string –string “Host: http://my-ip:8080/the-rest-of-the-address” –algo kmp -j ACCEPT
sbin/iptables -I INPUT -p tcp –dport 8080 -m string –string “Host: http://my-ip:8080/” –algo kmp -j DROP

相关内容