{"id":176119,"date":"2013-04-09T20:36:02","date_gmt":"2013-04-09T16:36:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=176119"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=176119","title":{"rendered":"<span class=\"post_title\">\u041e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0440\u0435\u0430\u043a\u0446\u0438\u044f \u043d\u0430 DDoS-\u0430\u0442\u0430\u043a\u0438<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041e\u0434\u0438\u043d \u0438\u0437 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u043f\u0440\u0438\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e, \u0432\u0434\u0440\u0443\u0433 \u0441\u0442\u0430\u043b \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u043a\u0430\u043a \u0443 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u0430\u043a \u0438 \u0443 \u043f\u043b\u043e\u0445\u0438\u0445. \u041c\u043e\u0449\u043d\u043e\u0435, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u0436\u0435\u043b\u0435\u0437\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439. \u0421\u043e\u0444\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441\u0430\u043c\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u2014 Linux,Nginx,PHP-FPM(+APC),MySQL, \u0432\u0435\u0440\u0441\u0438\u0438 \u2014 \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435. \u041d\u0430 \u0441\u0430\u0439\u0442\u0430\u0445 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f Drupal \u0438 phpBB. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u043e\u0444\u0442\u0430 (memcached, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0431\u0430\u0437\u0435, \u0433\u0434\u0435 \u0438\u0445 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e) \u0447\u0443\u0442\u044c \u043f\u043e\u043c\u043e\u0433\u043b\u0430, \u043d\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0435 \u0440\u0435\u0448\u0438\u043b\u0430. \u0410 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a \u0441\u0442\u0430\u0442\u0438\u043a\u0435, \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0435 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0431\u0430\u0437\u0435. \u041f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u044b \u0432 Nginx:<\/p>\n<p>  \u043d\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f  <\/p>\n<pre><code class=\"nginx\">limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn perip 100; <\/code><\/pre>\n<p>  \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443 (fastcgi_pass \u043d\u0430 php-fpm)  <\/p>\n<pre><code class=\"nginx\">limit_req_zone $binary_remote_addr zone=dynamic:10m rate=2r\/s; limit_req zone=dynamic burst=10 nodelay; <\/code><\/pre>\n<p>  \u0421\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0433\u0447\u0430\u043b\u043e, \u043f\u043e \u043b\u043e\u0433\u0430\u043c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u0437\u043e\u043d\u0443 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442, \u0437\u0430\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u0439.<\/p>\n<p>  \u041d\u043e \u043f\u043b\u043e\u0445\u0438\u0448\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u0434\u043e\u043b\u0431\u0438\u0442\u044c, \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u0445 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u2014 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430, \u0438 \u043d\u0430\u0434\u043e\u043b\u0433\u043e.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0430\u043c \u043f\u0430\u0440\u0441\u0438\u043b \u043b\u043e\u0433\u0438, \u0438 \u043e\u0441\u043e\u0431\u043e \u043d\u0430\u0441\u0442\u044b\u0440\u043d\u044b\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0447\u0435\u0440\u0435\u0437 iptables \u0432 \u0431\u0430\u043d\u044e. \u041f\u043e\u0442\u043e\u043c \u043f\u0430\u0440\u0441\u0438\u043b \u0443\u0436\u0435 \u043f\u043e \u043a\u0440\u043e\u043d\u0443 \u043a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442. \u041f\u0440\u043e\u0431\u043e\u0432\u0430\u043b fail2ban. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043f\u043b\u043e\u0445\u0438\u0448\u0435\u0439 \u0441\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e, \u043f\u0435\u0440\u0435\u043d\u0451\u0441 \u0438\u0445 \u0432 ipset ip hash.<\/p>\n<p>  \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0442\u0430\u043b\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b:<br \/>   \u2014 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\/\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043b\u043e\u0433\u043e\u0432 \u0442\u043e\u0436\u0435 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u0435 (\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0435) \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043d\u0438\u043c\u0430\u0435\u0442<br \/>   \u2014 \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0443\u043f\u0438\u0442, \u0435\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u043d\u043e\u0432\u0430\u044f \u0432\u043e\u043b\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u043a\u0430\u043c\u0438 (\u043b\u043e\u0433\u043e\u0432)<\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0435\u043b\u0435\u0439 \u0432 \u0447\u0435\u0440\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u044b\u043b\u0430 \u0438\u0434\u0435\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c\/\u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u043a Nginx + \u0434\u0435\u043c\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 ipset-\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u0438 \u0431\u0435\u0437 \u0434\u0435\u043c\u043e\u043d\u0430, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Nginx \u043e\u0442 \u0440\u0443\u0442\u0430, \u0447\u0442\u043e \u043d\u0435 \u0435\u0441\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0435\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0448\u0451\u043b (\u043c\u043e\u0436\u0435\u0442 \u043f\u043b\u043e\u0445\u043e \u0438\u0441\u043a\u0430\u043b?), \u0438 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  \u041f\u0440\u0438 \u043f\u0440\u0438\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043b\u0438\u043c\u0438\u0442\u0430, Nginx \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 503-\u044e\u044e \u043e\u0448\u0438\u0431\u043a\u0443 Service Temporarily Unavailable. \u0412\u043e\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430 \u043d\u0435\u0451 \u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u0438\u0442\u044c\u0441\u044f!<\/p>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e location \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439  <\/p>\n<pre><code class=\"nginx\">error_page 503 =429 @blacklist; <\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 location  <\/p>\n<pre><code class=\"nginx\">location @blacklist {     fastcgi_pass    localhost:1234;     fastcgi_param   SCRIPT_FILENAME    \/data\/web\/cgi\/blacklist.sh;     include         fastcgi_params; } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0439.<br \/>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 CGI-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0421\u0442\u0430\u0432\u0438\u043c, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c spawn-fcgi \u0438 fcgiwrap. \u0423 \u043c\u0435\u043d\u044f \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0434\u043b\u044f collectd.<\/p>\n<p>  \u0421\u0430\u043c CGI-\u0441\u043a\u0440\u0438\u043f\u0442<br \/>  <a name=\"habracut\"><\/a><\/p>\n<pre><code class=\"bash\">#!\/bin\/bash  BAN_TIME=5 DB_NAME=&quot;web_black_list&quot; SQLITE_DB=&quot;\/data\/web\/cgi\/${DB_NAME}.sqlite3&quot; CREATE_TABLE_SQL=&quot;\\ CREATE TABLE $DB_NAME (\\     ip varchar(16) NOT NULL PRIMARY KEY,\\     added DATETIME NOT NULL DEFAULT (DATETIME()),\\     updated DATETIME NOT NULL DEFAULT (DATETIME()),\\     counter INTEGER NOT NULL DEFAULT 0 )&quot; ADD_ENTRY_SQL=&quot;INSERT OR IGNORE INTO $DB_NAME (ip) VALUES (\\&quot;$REMOTE_ADDR\\&quot;)&quot; UPD_ENTRY_SQL=&quot;UPDATE $DB_NAME SET updated=DATETIME(), counter=(counter+1) WHERE ip=\\&quot;$REMOTE_ADDR\\&quot;&quot; SQLITE_CMD=&quot;\/usr\/bin\/sqlite3 $SQLITE_DB&quot; IPSET_CMD=&quot;\/usr\/sbin\/ipset&quot;  $IPSET_CMD add $DB_NAME $REMOTE_ADDR &gt; \/dev\/null 2&gt;&1  if [ ! -f $SQLITE_DB ]; then      $SQLITE_CMD &quot;$CREATE_TABLE_SQL&quot; fi  $SQLITE_CMD &quot;$ADD_ENTRY_SQL&quot; $SQLITE_CMD &quot;$UPD_ENTRY_SQL&quot;  echo &quot;Content-type: text\/html&quot; echo &quot;&quot;  echo &quot;&lt;html&gt;&quot; echo &quot;&lt;head&gt;&lt;title&gt;429 Too Many Requests&lt;\/title&gt;&lt;\/head&gt;&quot; echo &quot;&lt;body bgcolor=\\&quot;white\\&quot;&gt;&quot; echo &quot;&lt;center&gt;&lt;h1&gt;429 Too Many Requests&lt;\/h1&gt;&lt;\/center&gt;&quot; echo &quot;&lt;center&gt;&lt;small&gt;&lt;p&gt;Your address ($REMOTE_ADDR) is blacklisted for $BAN_TIME minutes&lt;\/p&gt;&lt;\/small&gt;&lt;\/center&gt;&quot; echo &quot;&lt;hr&gt;&lt;center&gt;$SERVER_SOFTWARE&lt;\/center&gt;&quot; echo &quot;&lt;\/body&gt;&quot; echo &quot;&lt;\/html&gt;&quot; <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0441\u0451 \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u043a\u0440\u043e\u043c\u0435, \u0440\u0430\u0437\u0432\u0435 \u0447\u0442\u043e, SQLite. \u042f \u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u043f\u043e\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043b\u044f \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0438, \u043d\u043e \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u043f\u043b\u043e\u0445\u0438\u0448\u0435\u0439 \u0438\u0437 \u0447\u0435\u0440\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430. \u0412\u0440\u0435\u043c\u044f 5 \u043c\u0438\u043d\u0443\u0442 \u043f\u043e\u043a\u0430 \u0442\u043e\u0436\u0435 \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f.<\/p>\n<p>  \u0427\u0435\u0440\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0441\u044f \u0432\u043e\u0442 \u0442\u0430\u043a  <\/p>\n<pre><code class=\"bash\">ipset create web_black_list hash:ip <\/code><\/pre>\n<p>  \u041f\u0440\u0430\u0432\u0438\u043b\u043e \u0432 iptables \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u043e\u0451, \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 \u0444\u0430\u043d\u0442\u0430\u0437\u0438\u0438.<\/p>\n<p>  \u0417.\u042b.: \u0423\u043b\u044b\u0431\u043d\u0443\u043b\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u00ab\u0445\u0430\u043a\u0435\u0440\u0430\u00bb \u043d\u0430 \u0444\u043e\u0440\u0443\u043c\u0435, \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u043e\u043d \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0441\u0435\u0440\u0432\u0435\u0440. \u041e\u043d \u0438 \u043d\u0435 \u0434\u043e\u0433\u0430\u0434\u044b\u0432\u0430\u043b\u0441\u044f, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0435\u0440\u0432\u0435\u0440 \u043f\u043e\u043b\u043e\u0436\u0438\u043b \u043d\u0430 \u043d\u0435\u0433\u043e. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/176119\/\"> http:\/\/habrahabr.ru\/post\/176119\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041e\u0434\u0438\u043d \u0438\u0437 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u044f \u043f\u0440\u0438\u0441\u043c\u0430\u0442\u0440\u0438\u0432\u0430\u044e, \u0432\u0434\u0440\u0443\u0433 \u0441\u0442\u0430\u043b \u043d\u0435\u043e\u0436\u0438\u0434\u0430\u043d\u043d\u043e \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u044b\u043c \u043a\u0430\u043a \u0443 \u0445\u043e\u0440\u043e\u0448\u0438\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u0442\u0430\u043a \u0438 \u0443 \u043f\u043b\u043e\u0445\u0438\u0445. \u041c\u043e\u0449\u043d\u043e\u0435, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u0436\u0435\u043b\u0435\u0437\u043e \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043b\u043e \u0441\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0441 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439. \u0421\u043e\u0444\u0442 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u0441\u0430\u043c\u044b\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u2014 Linux,Nginx,PHP-FPM(+APC),MySQL, \u0432\u0435\u0440\u0441\u0438\u0438 \u2014 \u0441\u0430\u043c\u044b\u0435 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435. \u041d\u0430 \u0441\u0430\u0439\u0442\u0430\u0445 \u043a\u0440\u0443\u0442\u0438\u0442\u0441\u044f Drupal \u0438 phpBB. \u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0441\u043e\u0444\u0442\u0430 (memcached, \u0438\u043d\u0434\u0435\u043a\u0441\u044b \u0432 \u0431\u0430\u0437\u0435, \u0433\u0434\u0435 \u0438\u0445 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e) \u0447\u0443\u0442\u044c \u043f\u043e\u043c\u043e\u0433\u043b\u0430, \u043d\u043e \u043a\u0430\u0440\u0434\u0438\u043d\u0430\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043d\u0435 \u0440\u0435\u0448\u0438\u043b\u0430. \u0410 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u2014 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043a \u0441\u0442\u0430\u0442\u0438\u043a\u0435, \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0435 \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0431\u0430\u0437\u0435. \u041f\u043e\u0441\u0442\u0430\u0432\u0438\u043b \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u043b\u0438\u043c\u0438\u0442\u044b \u0432 Nginx:<\/p>\n<p>  \u043d\u0430 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f  <\/p>\n<pre><code class=\"nginx\">limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn perip 100; <\/code><\/pre>\n<p>  \u0438 \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430 \u0434\u0438\u043d\u0430\u043c\u0438\u043a\u0443 (fastcgi_pass \u043d\u0430 php-fpm)  <\/p>\n<pre><code class=\"nginx\">limit_req_zone $binary_remote_addr zone=dynamic:10m rate=2r\/s; limit_req zone=dynamic burst=10 nodelay; <\/code><\/pre>\n<p>  \u0421\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u043b\u0435\u0433\u0447\u0430\u043b\u043e, \u043f\u043e \u043b\u043e\u0433\u0430\u043c \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043f\u0435\u0440\u0432\u0443\u044e \u0437\u043e\u043d\u0443 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442, \u0437\u0430\u0442\u043e \u0432\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u0439.<\/p>\n<p>  \u041d\u043e \u043f\u043b\u043e\u0445\u0438\u0448\u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u0434\u043e\u043b\u0431\u0438\u0442\u044c, \u0438 \u0437\u0430\u0445\u043e\u0442\u0435\u043b\u043e\u0441\u044c \u0438\u0445 \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0442\u044c \u0440\u0430\u043d\u044c\u0448\u0435 \u2014 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u0444\u0430\u0435\u0440\u0432\u043e\u043b\u0430, \u0438 \u043d\u0430\u0434\u043e\u043b\u0433\u043e.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u0430\u043c \u043f\u0430\u0440\u0441\u0438\u043b \u043b\u043e\u0433\u0438, \u0438 \u043e\u0441\u043e\u0431\u043e \u043d\u0430\u0441\u0442\u044b\u0440\u043d\u044b\u0445 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u043b \u0447\u0435\u0440\u0435\u0437 iptables \u0432 \u0431\u0430\u043d\u044e. \u041f\u043e\u0442\u043e\u043c \u043f\u0430\u0440\u0441\u0438\u043b \u0443\u0436\u0435 \u043f\u043e \u043a\u0440\u043e\u043d\u0443 \u043a\u0430\u0436\u0434\u044b\u0435 5 \u043c\u0438\u043d\u0443\u0442. \u041f\u0440\u043e\u0431\u043e\u0432\u0430\u043b fail2ban. \u041a\u043e\u0433\u0434\u0430 \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043f\u043b\u043e\u0445\u0438\u0448\u0435\u0439 \u0441\u0442\u0430\u043b\u043e \u043e\u0447\u0435\u043d\u044c \u043c\u043d\u043e\u0433\u043e, \u043f\u0435\u0440\u0435\u043d\u0451\u0441 \u0438\u0445 \u0432 ipset ip hash.<\/p>\n<p>  \u041f\u043e\u0447\u0442\u0438 \u0432\u0441\u0451 \u0445\u043e\u0440\u043e\u0448\u043e \u0441\u0442\u0430\u043b\u043e, \u043d\u043e \u0435\u0441\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b:<br \/>   \u2014 \u043f\u0430\u0440\u0441\u0438\u043d\u0433\/\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u043a\u0430 \u043b\u043e\u0433\u043e\u0432 \u0442\u043e\u0436\u0435 \u043f\u0440\u0438\u043b\u0438\u0447\u043d\u043e\u0435 (\u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043d\u043e\u0435) \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043d\u0438\u043c\u0430\u0435\u0442<br \/>   \u2014 \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0443\u043f\u0438\u0442, \u0435\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u043b\u0430\u0441\u044c \u043d\u043e\u0432\u0430\u044f \u0432\u043e\u043b\u043d\u0430 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u043c\u0438 \u0440\u0430\u0437\u0431\u043e\u0440\u043a\u0430\u043c\u0438 (\u043b\u043e\u0433\u043e\u0432)<\/p>\n<p>  \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c \u043a\u0430\u043a \u0431\u044b\u0441\u0442\u0440\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c \u043d\u0430\u0440\u0443\u0448\u0438\u0442\u0435\u043b\u0435\u0439 \u0432 \u0447\u0435\u0440\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0431\u044b\u043b\u0430 \u0438\u0434\u0435\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c\/\u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u043a Nginx + \u0434\u0435\u043c\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 ipset-\u044b \u043e\u0431\u043d\u043e\u0432\u043b\u044f\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u0438 \u0431\u0435\u0437 \u0434\u0435\u043c\u043e\u043d\u0430, \u043d\u043e \u0442\u043e\u0433\u0434\u0430 \u043f\u0440\u0438\u0434\u0451\u0442\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c Nginx \u043e\u0442 \u0440\u0443\u0442\u0430, \u0447\u0442\u043e \u043d\u0435 \u0435\u0441\u0442\u044c \u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u043f\u043e\u043d\u044f\u043b, \u0447\u0442\u043e \u043d\u0435\u0442 \u0441\u0442\u043e\u043b\u044c\u043a\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u041d\u0438\u0447\u0435\u0433\u043e \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0448\u0451\u043b (\u043c\u043e\u0436\u0435\u0442 \u043f\u043b\u043e\u0445\u043e \u0438\u0441\u043a\u0430\u043b?), \u0438 \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u043b \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  \u041f\u0440\u0438 \u043f\u0440\u0438\u0432\u044b\u0448\u0435\u043d\u0438\u0438 \u043b\u0438\u043c\u0438\u0442\u0430, Nginx \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 503-\u044e\u044e \u043e\u0448\u0438\u0431\u043a\u0443 Service Temporarily Unavailable. \u0412\u043e\u0442 \u044f \u0440\u0435\u0448\u0438\u043b \u043d\u0430 \u043d\u0435\u0451 \u0438 \u043f\u0440\u0438\u0446\u0435\u043f\u0438\u0442\u044c\u0441\u044f!<\/p>\n<p>  \u0414\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e location \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0441\u0432\u043e\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439  <\/p>\n<pre><code class=\"nginx\">error_page 503 =429 @blacklist; <\/code><\/pre>\n<p>  \u0418 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 location  <\/p>\n<pre><code class=\"nginx\">location @blacklist {     fastcgi_pass    localhost:1234;     fastcgi_param   SCRIPT_FILENAME    \/data\/web\/cgi\/blacklist.sh;     include         fastcgi_params; } <\/code><\/pre>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0439.<br \/>  \u041d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 CGI-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432. \u0421\u0442\u0430\u0432\u0438\u043c, \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c, \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c spawn-fcgi \u0438 fcgiwrap. \u0423 \u043c\u0435\u043d\u044f \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0434\u043b\u044f collectd.<\/p>\n<p>  \u0421\u0430\u043c CGI-\u0441\u043a\u0440\u0438\u043f\u0442  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-176119","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=176119"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/176119\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=176119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=176119"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=176119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}