![CentOS - 如何告诉 IPtables 阻止世界但仅允许它们具有唯一的 url?](https://linux22.com/image/98737/CentOS%20-%20%E5%A6%82%E4%BD%95%E5%91%8A%E8%AF%89%20IPtables%20%E9%98%BB%E6%AD%A2%E4%B8%96%E7%95%8C%E4%BD%86%E4%BB%85%E5%85%81%E8%AE%B8%E5%AE%83%E4%BB%AC%E5%85%B7%E6%9C%89%E5%94%AF%E4%B8%80%E7%9A%84%20url%EF%BC%9F.png)
我有以下 iptables。但现在我需要允许该服务器中的任何人(如果他有唯一的网址):www.example.com/IamEncodedencodedencodedencodedencodedencoded_Allow_Me
$ yum install iptables-services
$ cat /etc/sysconfig/iptables
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
# 1 ############ My office ##########
-A INPUT -s 217.1.2.3 -j ACCEPT
-A INPUT -s 82.1.2.3 -j ACCEPT
############# My office END ######
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
# 2 ########### Service center ############
-A INPUT -s 18.16.0.0/16 -j ACCEPT
############ Service center END ############
-A INPUT -j DROP
COMMIT
$ systemctl restart iptables
$ systemctl reload iptables
编辑:
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -s 217.1.2.3 -j ACCEPT
-A INPUT -s 82.1.2.3 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -s 18.16.0.0/16 -j ACCEPT
-A INPUT -j DROP
-A INPUT -p tcp --dport 80 -j ACCEPT
COMMIT
答案1
如果您想允许从浏览器访问并且您正在使用阿帕奇作为网络服务器,那么您可以添加以下行阿帕奇配置并启动服务。
#Deny the access to everything first
<Location />
Order Deny,Allow
Deny from All
</Location>
# then allow access to specific URL
<Location /test.html>
Order Allow,Deny
Allow from All
</Location>
如果是这种情况,这个问题之前已经回答过这里。