记两个配置问题

注意:本文最后更新于 2530 天前,有关的内容可能已经发生变化,请参考使用。

首先是关于PHP在PHP 5.2以上启用safe_mode or an open_basedir会导致CURLOPT_FOLLOWLOCATION失败,再导致curl_setopt/curl_setopt_array失败。官方对此有声明如下:

    Starting in PHP 5.2.0, CURLOPT_FOLLOWLOCATION can't be set via
    curl_setopt_array() (or curl_setopt()) when either safe_mode is
    enabled or open_basedir is set. In these cases, the order of CURLOPT_*
    settings in the array can be important.
    
    1.CURLOPT_FOLLOWLOCATION Warning: curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated
    when in safe_mode or an open_basedir is set
    2.curl_setopt_array()

如果curl_setopt_array中包含CURLOPT_FOLLOWLOCATION键值,会导致所有options设置失败,让你感觉curl_setopt_array有问题,其实这个函数本身是没问题的。

对此我尝试用这种方法:在php.ini中设置open_basedir或者safe_mode,再在Apache(或者Nginx的FastCGI)中<Directory>、<VirtualHost>设置 php_admin_value open_basedir Off。结果是相应的虚拟主机整个PHP跑不了了,不知道为何。

所以目前来看对于需要使用curl_setopt_array()的环境应该就不能打开safe_mode和设置open_basedir值了。


第二个是关于ipf的IPF.conf设置的。

网上看似有不少关于ipf的文档,包括man ipf看上去也把ipf的设置讲解得十分的详细,但是实际上有一些非常细节的内容让人相当纠结。可能是由于我从一开始在概念上的理解就存在问题,在此总结一下;首先看我之前一直在用的一个ipf.conf规则:

    pass in quick from any to 202.101.208.35 mask 255.255.255.255 port = 22 keep state
    pass in quick from any to 202.101.208.35 mask 255.255.255.255 port = 80 keep state 
    pass in quick from any to 202.101.208.35 mask 255.255.255.255 port = 443 keep state 
    pass out all keep state

即在每条规则后面添加keep state问题就解决了…… 一开始老认为都pass out all了,干嘛还要特别在in的部分申明keep state……现在才终于知道为什么


「倘若有所帮助,不妨酌情赞赏!」

Holmesian

感谢您的支持!

使用微信扫描二维码完成支付


相关文章

发表新评论