{"id":1240,"date":"2014-09-14T09:49:21","date_gmt":"2014-09-14T09:49:21","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=1240"},"modified":"2014-09-14T09:49:21","modified_gmt":"2014-09-14T09:49:21","slug":"%e7%bd%91%e7%ab%99%e9%85%8d%e7%bd%ae%e7%9a%84%e5%ae%89%e5%85%a8%e6%a3%80%e6%9f%a5","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/1240.html","title":{"rendered":"\u7f51\u7ad9\u914d\u7f6e\u7684\u5b89\u5168\u68c0\u67e5"},"content":{"rendered":"<p>\u56e0\u4e3a\u505a\u5b89\u5168\u4e5f\u6709\u4e00\u6bb5\u65f6\u95f4\u4e86\uff0c\u5bf9\u5b89\u5168\u8fd9\u65b9\u9762\u7684\u95ee\u9898\u4f1a\u8f83\u4e3a\u654f\u611f\uff0c\u7279\u522b\u662f\u5728\u524d\u4e9b\u5929\u56e0\u4e3a\u81ea\u5df1\u7684\u5931\u8bef\u5bfc\u81f4\u7f51\u7ad9\u51fa\u73b0Nginx 502 gateway error\u7684\u9519\u8bef\uff0c\u8ba9\u6211\u89c9\u5f97\u6709\u5fc5\u8981\u5728\u5468\u672b\u6709\u7a7a\u7684\u65f6\u5019\u5bf9\u7f51\u7ad9\u7684\u4e00\u4e9b\u914d\u7f6e\u8fdb\u884c\u5168\u9762\u7684\u68c0\u67e5\uff08\u6211\u53ef\u4e0d\u60f3\u518d\u51fa\u4ec0\u4e48\u5c94\u5b50\u4e86\uff0c\u5199blog\u672c\u6765\u5c31\u662f\u4e3a\u4e86\u8bb0\u5f55\u4e00\u4e9b\u5185\u5bb9\uff0c\u5206\u4eab\u4e00\u4e9b\u5fc3\u5f97\u7684\uff0c\u522b\u5f04\u5230\u6700\u540e\u88ab\u9ed1\u4e86\u53ef\u5c31\u592a\u4e0d\u8ba9\u4eba\u7701\u5fc3\u4e86\uff0c\u8fd9\u79cd\u6709\u8fdd\u521d\u8877\u7684\u4e8b\u60c5\u6211\u53ef\u4e0d\u80fd\u8ba9\u5b83\u53d1\u751f\uff09\u3002<\/p>\n<h5>1.PHP\u914d\u7f6e\u6587\u4ef6php.ini\u7684\u68c0\u67e5<\/h5>\n<p>php.ini\u8fd9\u4e2a\u6587\u4ef6\u5927\u90e8\u5206\u505a\u5b89\u5168\u7684\u4eba\u5e94\u8be5\u90fd\u4f1a\u6bd4\u8f83\u4e86\u89e3\u4e86\uff0c\u4e3b\u8981\u68c0\u67e5\u7684\u4e5f\u5c31\u90a3\u4e48\u51e0\u70b9\uff1a\u9632\u6ce8\u5165\u68c0\u67e5magic_quotes_gpc(\u9700\u8981\u6ce8\u610f\u4e0d\u8981\u8ba9magic_quotes_sybase\u7684\u503c\u8986\u76d6\u4e86)\u3001\u9632\u8de8\u7ad9\/\u8de8\u76ee\u5f55\u68c0\u67e5open_basedir\u3001\u8fd8\u6709\u7248\u672c\u663e\u793a\/\u9519\u8bef\u663e\u793a\u7b49\u8bbe\u7f6e\uff08register_globals\/disable_functions\/log_errors\/error_log\/error_reporting\/display_errors\/allow_url_fopen\/allow_url_include\/expose_php\/memory_limit\/cgi.fix_pathinfo\/session.cookie_httponly\/disable_classes\uff09\u9700\u8981\u6839\u636e\u81ea\u5df1\u7684\u5177\u4f53\u9700\u6c42\u8fdb\u884c\u914d\u7f6e\uff0c\u5b89\u5168\u6709\u65f6\u5019\u4e5f\u662f\u5f97\u9700\u8981\u7ed9\u4e1a\u52a1\u8ba9\u6b65\u7684\u3002<\/p>\n<p>\u624b\u5de5\u4e00\u4e2a\u4e2a\u7684\u67e5\u770b\u592a\u4e0d\u79d1\u5b66\uff0c\u8fd8\u5bb9\u6613\u51fa\u9519\uff0c\u6240\u4ee5\u8fd9\u91cc\u6211\u4f7f\u7528\u521a\u53d1\u73b0\u7684\u4e00\u4e2aPHP\u914d\u7f6e\u68c0\u6d4b\u5de5\u5177<a href=\"https:\/\/github.com\/sektioneins\/pcc\" target=\"_blank\">PCC<\/a>\uff0c\u5728FreeBuf\u4e0a\u6709\u5bf9\u5e94\u7684<a title=\"PHP\u914d\u7f6e\u5b89\u5168\u68c0\u67e5\u5de5\u5177 \u2013 PCC\" href=\"http:\/\/www.freebuf.com\/tools\/43191.html\" target=\"_blank\">\u4ecb\u7ecd<\/a>\uff0c\u8fd9\u91cc\u6211\u53ea\u8bf4\u5728\u4f7f\u7528\u7684\u8fc7\u7a0b\u4e2d\u78b0\u5230\u7684\u4e00\u4e2a\u5c0f\u95ee\u9898\u201cAccess denied. &#8211; Your IP is not cleared. Please set PCC_ALLOW_IP to a your IP address or a wildcard pattern, e.g. &#8216;SetEnv PCC_ALLOW_IP 10.0.0.*&#8217;\u201d\uff0c\u5728\u78b0\u5230\u8fd9\u79cd\u95ee\u9898\u7684\u65f6\u5019\u7b2c\u4e00\u60f3\u6cd5\u5c31\u662f\u53bbgithub\u4e0a\u627e\u4f7f\u7528\u8bf4\u660e\uff0c\u4e8e\u662f\u5c31\u6709\uff1a<\/p>\n<p>Most of the time it is a good idea to keep security related issues such as your PHP configuration to yourself. The following safeguards have been implemented:<\/p>\n<ul class=\"task-list\">\n<li><strong>mtime check<\/strong>: This script stops working in non-CLI mode after two days. Re-arming the check can be done by <code>touch phpconfigcheck.php<\/code> or by copying the script to your server again (e.g. via SCP). This check can be disabled by setting the environment variable: <code>PCC_DISABLE_MTIME=1<\/code>, e.g. <code>SetEnv PCC_DISABLE_MTIME 1<\/code> in apache&#8217;s <code>.htaccess<\/code>.<\/li>\n<li><strong>source IP check<\/strong>: <span style=\"color: #ff0000;\"><strong>By default only localhost (127.0.0.1 and ::1) can access this script.<\/strong><\/span> Other hosts may be added by setting <code>PCC_ALLOW_IP<\/code> to a your IP address or a wildcard pattern, e.g. <code>SetEnv PCC_ALLOW_IP 10.0.0.*<\/code> in <code>.htaccess<\/code>. You may also choose to access your webserver via SSH Port forwarding, e.g. <code>ssh -D<\/code> or <code>ssh -L<\/code>.\uff08\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u53ea\u6709\u672c\u5730\u53ef\u4ee5\u901a\u8fc7\u7c7b\u4f3c\u4e8ehttp:\/\/localhost\/phpconfigcheck.php?showall=1\u7684\u65b9\u5f0f\u8fdb\u884c\u8bbf\u95ee\uff0c\u5176\u5b83\u7684\u4e3b\u673a\u5982\u679c\u60f3\u8981\u76f4\u63a5\u901a\u8fc7\u8be5URL\u8fdb\u884c\u8bbf\u95ee\u7684\u8bdd\uff0c\u9700\u8981\u8bbe\u7f6e\u8bbf\u95ee\u6743\u9650\uff1a\u5bf9\u4e8eApache\u6765\u8bf4\u5c31\u662f\u8bbe\u7f6e.htaccess\u6587\u4ef6\uff0c\u6dfb\u52a0\u6307\u5b9a\u7684IP\u81f3\u767d\u540d\u5355\uff1b\u6216\u8005\u4f7f\u7528SSH\u7aef\u53e3\u8f6c\u53d1\u7684\u65b9\u5f0f\u4e5f\u884c\uff09<\/li>\n<\/ul>\n<p>\u8fd9\u91cc\u6211\u5c31\u76f4\u63a5\u4f7f\u7528CLI\u7684\u65b9\u5f0f\u68c0\u67e5\u4e86\uff1aphp\u00a0phpconfigcheck.php &gt;check_php.ini.log\uff0c\u7136\u540e\u6162\u6162\u5206\u6790\uff0c\u6709\u95ee\u9898\u5c31\u6539\u3002<\/p>\n<p>\u81ea\u5df1\u4e5f\u53ef\u4ee5\u5199\u811a\u672c\u8fdb\u884c\u81ea\u52a8\u5316\u68c0\u67e5\u3001\u4fee\u6539\uff0c\u8fd8\u53ef\u4ee5\u7ec3\u4e60\u81ea\u5df1\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\uff0c\u8fd9\u91cc\u5c31\u4e0d\u653e\u81ea\u5df1\u7684\u811a\u672c\u4e86\uff0c\u5199\u7684\u592a\u632bo(\u256f\u25a1\u2570)o<\/p>\n<h5>2.Nginx\u914d\u7f6e\u6587\u4ef6nginx.conf\u7684\u68c0\u67e5<\/h5>\n<p>\u4e3b\u8981\u6709\uff1a<\/p>\n<ul>\n<li>\u914d\u7f6enginx.conf \u4fee\u6539Nginx\u7684\u8fd0\u884c\u8d26\u6237\u4e3anobody<\/li>\n<li>\u914d\u7f6enginx.conf \u5bf9\u4e8e\u4e0a\u4f20\u76ee\u5f55\u65e0PHP\u7684\u6267\u884c\u6743\u9650<\/li>\n<li>\u914d\u7f6enginx.conf \u7981\u6b62\u8bbf\u95ee\u7684\u6587\u4ef6\u5939\uff0c\u5982\u540e\u53f0\uff0c\u6216\u8005\u9650\u5236\u8bbf\u95eeIP<\/li>\n<li>\u914d\u7f6enginx.conf \u7981\u6b62\u8bbf\u95ee\u7684\u6587\u4ef6\u7c7b\u578b\uff0c\u5982\u4e00\u4e9btxt\u65e5\u5fd7\u6587\u4ef6<\/li>\n<\/ul>\n<h5>3.php-fpm\u7684\u914d\u7f6e\u6587\u4ef6php-fpm.conf\u7684\u68c0\u67e5<\/h5>\n<p>\u4fee\u6539php-fpm\u7684\u8fd0\u884c\u8d26\u6237\u548c\u7ec4\u4e3anobody<\/p>\n<p>&nbsp;<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/php.net\/manual\/zh\/ini.core.php\" target=\"_blank\">PHP: php.ini \u6838\u5fc3\u914d\u7f6e\u9009\u9879\u8bf4\u660e<\/a><\/li>\n<li><a href=\"http:\/\/nginx.org\/en\/docs\/\" target=\"_blank\">nginx documentation<\/a><\/li>\n<li><a href=\"http:\/\/drops.wooyun.org\/tips\/1323\" target=\"_blank\">Nginx\u5b89\u5168\u914d\u7f6e\u7814\u7a76 | WooYun\u77e5\u8bc6\u5e93<\/a><\/li>\n<li><a href=\"http:\/\/drops.wooyun.org\/tips\/2245\" target=\"_blank\">Mysql\u5b89\u5168\u914d\u7f6e | WooYun\u77e5\u8bc6\u5e93<\/a><\/li>\n<li><a href=\"http:\/\/ixyzero.com\/blog\/archives\/991.html\" target=\"_blank\">[collect]\u8fd0\u7ef4\u5b89\u5168 | ASPIRE<\/a><\/li>\n<li><a href=\"http:\/\/www.nginx.cn\/76.html\" target=\"_blank\">nginx\u57fa\u672c\u914d\u7f6e\u4e0e\u53c2\u6570\u8bf4\u660e<\/a><\/li>\n<li><a href=\"http:\/\/www.nginx.cn\/231.html\" target=\"_blank\">nginx php-fpm\u5b89\u88c5\u914d\u7f6e<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u56e0\u4e3a\u505a\u5b89\u5168\u4e5f\u6709\u4e00\u6bb5\u65f6\u95f4\u4e86\uff0c\u5bf9\u5b89\u5168\u8fd9\u65b9\u9762\u7684\u95ee\u9898\u4f1a\u8f83\u4e3a\u654f\u611f\uff0c\u7279\u522b\u662f\u5728\u524d\u4e9b\u5929\u56e0\u4e3a\u81ea\u5df1\u7684\u5931\u8bef\u5bfc\u81f4\u7f51\u7ad9\u51fa\u73b0Nginx 5 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,25,12],"tags":[337,338],"class_list":["post-1240","post","type-post","status-publish","format-standard","hentry","category-linux","category-security","category-tools","tag-nginx-conf","tag-php-ini"],"views":5324,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1240","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=1240"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/1240\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=1240"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=1240"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=1240"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}