【问题标题】:allow redirects with iptables [closed]允许使用 iptables 进行重定向 [关闭]
【发布时间】:2013-04-11 05:12:12
【问题描述】:

使用以下规则,php 不能将redirect 生成另一个文件。它在到达header("Content-type: video/x-flv"); header("Location:" . $VIDEO); 或可能是我的 php 脚本上的 get_headers(); 时冻结。

我的 iptables:

 iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:22151 
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:http 
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:webcache 
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:webcache 
ACCEPT     tcp  --  anywhere             anywhere            tcp spt:http 
DROP       all  --  anywhere             anywhere            

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination     

我试过的

iptables -A INPUT -p ICMP --icmp-type 8 -j ACCEPT

我删除 DROP all -- anywhere anywhere 后一切正常。

【问题讨论】:

  • 您的规则都没有根据 HTTP 流量的内容进行过滤,所以我认为问题不是您认为的那样。
  • 没关系,但在重定向时不需要发送Content-type 标头。客户端会忽略您发送的内容,而是转到 Location 标头中的页面。您是说这些 iptables 规则阻止客户端接收 Location 标头?
  • @Barmar 是的。或者它可能停在get_headers();

标签: linux security ubuntu iptables


【解决方案1】:

当您使用get_headers() 时,您的脚本会建立一个传出 HTTP 连接。您需要通过允许已建立会话来允许回复流量返回。

sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT

更多信息请见here

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-06
    • 2018-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多