允许使用iptables重定向

时间:2013-04-10 20:47:56

标签: linux security ubuntu iptables

使用以下规则,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后一切正常。

1 个答案:

答案 0 :(得分:1)

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

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

有关详细信息,请参阅here