{"id":304325,"date":"2020-05-27T09:00:50","date_gmt":"2020-05-27T09:00:50","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=304325"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=304325","title":{"rendered":"\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 GeoIP ACL \u0432 HAProxy \u0432 \u0434\u0432\u0430 \u0448\u0430\u0433\u0430"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/502168\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7q\/dg\/dz\/7qdgdzgalavv30lucx95rbufjnw.jpeg\"><br \/>  <a href=\"https:\/\/www.deviantart.com\/augustinasraginskis\/art\/Hello-Planets-818681683\"><i>Hello Planets by Augustinas Raginskis<\/i><\/a><\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0433\u0435\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u2014 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a GeoIP \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 <a href=\"https:\/\/www.maxmind.com\/en\/home\">MaxMind<\/a>. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.<br \/>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c MaxMind<\/h2>\n<p>  \u0420\u0430\u043d\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f, \u0442\u0430\u043a \u043a\u0430\u043a MaxMind \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0432\u043e\u0438\u0445 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0434\u043b\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u0441\u0435\u0439\u0447\u0430\u0441 <a href=\"https:\/\/blog.maxmind.com\/2019\/12\/18\/significant-changes-to-accessing-and-using-geolite2-databases\/\">\u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u0440\u044f\u043c\u043e\u0433\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u044f \u0431\u0435\u0437 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430<\/a>. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e <a href=\"https:\/\/www.maxmind.com\/en\/geolite2\/signup\">\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0437\u0434\u0435\u0441\u044c<\/a>, \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0432 \u0444\u043e\u0440\u043c\u0443:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/229\/2ac\/b39\/2292acb39fa7370ec5b9e8803c86d905.png\"><\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0448\u0430\u0433\u0430 \u0432\u0430\u043c \u043d\u0430 \u043f\u043e\u0447\u0442\u0443 \u043f\u0440\u0438\u0434\u0435\u0442 \u043f\u0438\u0441\u044c\u043c\u043e \u0441 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c\u0438 \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u043c\u0438:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/f63\/169\/3cd\/f631693cdb8d7e99c5a5103a357b51d1.png\"><\/div>\n<p>  \u041f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 \u0434\u043b\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043f\u0430\u0440\u043e\u043b\u044f:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/93c\/bc5\/8ec\/93cbc58ec351a8b22ab3c01f8de664a6.png\"><\/div>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432\u044b \u043f\u043e\u043f\u0430\u0434\u0435\u0442\u0435 \u0432 \u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u0431\u0438\u043d\u0435\u0442:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/88d\/a34\/da8\/88da34da8a0e4f3750af4cdcdb758abf.png\"><\/div>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b MaxMind \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u043f\u0438\u0441\u0430\u0442\u044c \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u044e \u043d\u0430 \u0441\u0430\u0439\u0442\u0435. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0439\u0442\u0438 \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 My License Key:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/e54\/d00\/802\/e54d008028cc86e7bc088c915dd0c2be.png\"><\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/284\/41a\/d53\/28441ad53f1c9b8b35e4984a42deb7f1.png\"><\/div>\n<p>  \u0414\u0430\u043b\u0435\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/793\/cfc\/a2e\/793cfca2e41df86e57044c5539faa08c.png\"><\/div>\n<p>  \u041d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u0441\u044f \u043d\u043e\u043c\u0435\u0440 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u2014 \u043f\u043e\u0442\u043e\u043c \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0435\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043b\u044c\u0437\u044f, \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u0443\u044e \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u044e:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/d01\/4dd\/277\/d014dd2771d55b50d5e2788925934912.png\"><\/div>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c, \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438, \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 GeoIP. \u041a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c <a href=\"https:\/\/dev.maxmind.com\/geoip\/geoipupdate\/\">\u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u0443\u0442<\/a>.<\/p>\n<p>  \u0414\u0430\u043b\u044c\u0448\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435: <a href=\"https:\/\/www.maxmind.com\/en\/accounts\/current\/geoip\/downloads\">https:\/\/www.maxmind.com\/en\/accounts\/current\/geoip\/downloads<\/a>, \u0438 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u043c \u043b\u0438\u043d\u043a Get permalinks \u043d\u0430\u043f\u0440\u043e\u0442\u0438\u0432 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 GeoLite2 Country: CSV Format:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/460\/654\/902\/460654902c0e8eaf4f46cd4888caccd2.png\"><\/div>\n<p>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043e\u043a\u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u044b \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/8a9\/cda\/a4a\/8a9cdaa4a329cd62ffc9938f4e698d63.png\"><\/div>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c YOUR_LICENSE_KEY \u043d\u0430 \u0432\u0430\u0448\u0443 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u044e, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0432\u044b \u0432\u044b\u043f\u0438\u0441\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435.\u00a0<\/p>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0431\u0430\u0437\u044b GeoIP \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d\u0430, \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0435.<\/p>\n<h2>\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 HAProxy<\/h2>\n<p>  HAProxy \u043d\u0435 \u0443\u043c\u0435\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 \u0431\u0430\u0437\u0430\u043c\u0438 MaxMind, \u043e\u0434\u043d\u0430\u043a\u043e \u0443\u043c\u0435\u0435\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c ACL \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u043f\u0438\u0441\u043a\u043e\u0432 \u0441\u0435\u0442\u0435\u0439. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 HAProxy:<\/p>\n<pre><code class=\"xml\">frontend frontend-https     bind *:80  # GeoIP ACL     acl acl_SNG src -f \/etc\/haproxy\/geoip\/SNG.txt<\/code><\/pre>\n<p>  \u0421\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0444\u0430\u0439\u043b\u0430 \/etc\/haproxy\/geoip\/SNG.txt:<\/p>\n<pre><code class=\"xml\">... 188.215.252.0\/22 188.237.0.0\/16 188.240.70.0\/24 188.244.16.0\/20 191.96.60.0\/23 192.121.87.0\/24 193.8.167.0\/24 193.16.111.0\/24 193.17.78.0\/24 ...<\/code><\/pre>\n<p>  \u0422\u043e \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b SNG.txt \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043f\u0430\u0434\u0443\u0442 \u0432 ACL.<\/p>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0442\u0435\u0439 \u0438\u0437 \u0431\u0430\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 MaxMind.<\/p>\n<p>  \u0421\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u0434\u0430\u0447\u0443, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0440\u0435\u0448\u0438\u0442\u044c: \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e, \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0430\u0444\u0438\u043a \u0438\u0437 \u0420\u043e\u0441\u0441\u0438\u0438, \u0411\u0435\u043b\u0430\u0440\u0443\u0441\u0438 \u0438 \u0423\u043a\u0440\u0430\u0438\u043d\u044b \u0448\u0435\u043b \u043d\u0430 \u043e\u0434\u0438\u043d \u0431\u044d\u043a\u0435\u043d\u0434, \u0430 \u0442\u0440\u0430\u0444\u0438\u043a \u0438\u0437 \u0434\u0440\u0443\u0433\u0438\u0445 \u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u0443\u0445\u043e\u0434\u0438\u043b \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u0439 \u0431\u044d\u043a\u0435\u043d\u0434. \u0414\u043b\u044f \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c shell-\u0441\u043a\u0440\u0438\u043f\u0442. \u0421\u043a\u0440\u0438\u043f\u0442 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044d\u0442\u0430\u043f\u043e\u0432.<\/p>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0441\u0432\u0435\u0436\u0443\u044e \u043a\u043e\u043f\u0438\u044e \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 MaxMind \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 csv:<\/p>\n<pre><code class=\"xml\"># Download geoip2 lite csv database wget  &quot;https:\/\/download.maxmind.com\/app\/geoip_download?edition_id=GeoLite2-Country-CSV&amp;license_key=${MAXMIND_LICENSE}&amp;suffix=zip&quot; -qO geoip2lite.zip  &amp;&amp; unzip -j geoip2lite.zip<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c ${MAXMIND_LICENSE} \u2014 \u044d\u0442\u043e \u043d\u043e\u043c\u0435\u0440 \u043b\u0438\u0446\u0435\u043d\u0437\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u044b \u0432\u044b\u043f\u0438\u0441\u0430\u043b\u0438 \u0440\u0430\u043d\u0435\u0435 \u043d\u0430 \u0441\u0430\u0439\u0442\u0435 MaxMind.<\/p>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u0430\u0440\u0445\u0438\u0432\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"xml\">root@ash:\/tmp\/geo2lite# ls -1 COPYRIGHT.txt GeoLite2-Country-Blocks-IPv4.csv GeoLite2-Country-Blocks-IPv6.csv GeoLite2-Country-Locations-de.csv GeoLite2-Country-Locations-en.csv GeoLite2-Country-Locations-es.csv GeoLite2-Country-Locations-fr.csv GeoLite2-Country-Locations-ja.csv GeoLite2-Country-Locations-pt-BR.csv GeoLite2-Country-Locations-ru.csv GeoLite2-Country-Locations-zh-CN.csv LICENSE.txt README.txt<\/code><\/pre>\n<p>  \u041d\u0430\u0441 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0442 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u2014 GeoLite2-Country-Blocks-IPv4.csv, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0442\u0435\u0439 ipv4 \u0441\u0442\u0440\u0430\u043d\u0430\u043c, \u0438 GeoLite2-Country-Locations-en.csv, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0439 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0439 \u0441\u0442\u0440\u0430\u043d \u0446\u0438\u0444\u0440\u043e\u0432\u044b\u043c \u043a\u043e\u0434\u0430\u043c.<\/p>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0435\u0442\u0438, \u043f\u0440\u0438\u043d\u0430\u0434\u043b\u0435\u0436\u0430\u0449\u0438\u0435 \u0420\u043e\u0441\u0441\u0438\u0438, \u043c\u044b \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u0434 \u0420\u043e\u0441\u0441\u0438\u0438:<\/p>\n<pre><code class=\"xml\">root@ash:\/tmp\/geo2lite# cat GeoLite2-Country-Locations-en.csv | grep  Russia 2017370,en,EU,Europe,RU,Russia,0<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c 2017370 \u2014 \u044d\u0442\u043e \u0438\u0441\u043a\u043e\u043c\u044b\u0439 \u043a\u043e\u0434.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u043e \u043d\u0435\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0435\u0442\u0438.\u00a0<\/p>\n<pre><code class=\"xml\">root@ash:\/tmp\/geo2lite# cat GeoLite2-Country-Blocks-IPv4.csv | grep 2017370 ... 217.147.16.0\/20,2017370,2017370,,0,0 217.148.48.0\/20,2017370,2017370,,0,0 217.148.192.0\/19,2017370,2017370,,0,0 217.149.16.0\/20,2017370,2017370,,0,0 217.149.176.0\/20,2017370,2017370,,0,0 217.150.0.0\/18,2017370,2017370,,0,0 217.150.72.0\/21,2017370,2017370,,0,0 217.150.192.0\/20,2017370,2017370,,0,0<\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0447\u0438\u0441\u043b\u043e 2017370 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0434\u0432\u0430 \u0440\u0430\u0437\u0430. \u041e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 \u0444\u0430\u0439\u043b\u0430:<\/p>\n<pre><code class=\"xml\">root@ash:\/tmp\/geo2lite# cat GeoLite2-Country-Blocks-IPv4.csv | head -n 1 network,geoname_id,registered_country_geoname_id,represented_country_geo name_id,is_anonymous_proxy,is_satellite_provider<\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c registered_country_geoname_id \u2014 \u043a\u043e\u0434 \u0441\u0442\u0440\u0430\u043d\u044b, \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430 \u0441\u0435\u0442\u044c, \u0430 represented_country_geoname_id \u2014 \u043a\u043e\u0434 \u0441\u0442\u0440\u0430\u043d\u044b, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u0441\u0435\u0442\u0438.\u00a0<\/p>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u0430 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0442\u044c \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430 \u0420\u043e\u0441\u0441\u0438\u0435\u0439, \u0430 \u0440\u043e\u0443\u0442\u0438\u043d\u0433 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0413\u043e\u043b\u043b\u0430\u043d\u0434\u0438\u0438. \u041a\u0430\u043a \u043f\u043e\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u0432 \u0442\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u0440\u0435\u0448\u0430\u0439\u0442\u0435 \u0441\u0430\u043c\u0438, \u044f \u0432\u044b\u0431\u0438\u0440\u0430\u043b \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0442\u0438, \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0438 \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u044b\u0435 \u0438\u0437 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u044b.<\/p>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0431\u0438\u0440\u0430\u044f \u043d\u0443\u0436\u043d\u044b\u0435 \u0441\u0435\u0442\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u0430 GeoLite2-Country-Blocks-IPv4.csv, \u043c\u043e\u0436\u043d\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u0439\u043b \u0434\u043b\u044f HAProxy ACL.<\/p>\n<p>  \u0421\u0430\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 ACL \u0432 HAProxy:<\/p>\n<pre><code class=\"xml\">frontend frontend # GeoIP ACL     acl acl_SNG src -f \/etc\/haproxy\/geoip\/SNG.txt      use_backend backend1 if acl_SNG     default_backend backend2<\/code><\/pre>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0435\u0441\u043b\u0438 IP-\u0430\u0434\u0440\u0435\u0441 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0437 \u0441\u0435\u0442\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432 \u0444\u0430\u0439\u043b\u0435 SNG.txt, \u0442\u043e \u0437\u0430\u043f\u0440\u043e\u0441 \u0443\u0439\u0434\u0435\u0442 \u043d\u0430 backend1, \u0432 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u2014 \u043d\u0430 backend2.<\/p>\n<p>  \u0414\u043b\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0431\u044b\u043b \u043d\u0430\u043f\u0438\u0441\u0430\u043d \u0441\u043a\u0440\u0438\u043f\u0442:<\/p>\n<pre><code class=\"bash\">root@ash:~# cat haproxy_geoip_list.sh #!\/bin\/bash #----------------------------------------------------------------------------------------------------------------------- # Variables TMPDIR=&quot;\/tmp\/geo2lite&quot; MAXMIND_LICENSE=&quot;xxxxxxxxxxxxx&quot; LOCATIONS=&quot;Russia Ukraine Belarus&quot; HAPROXY_PATH=&quot;\/etc\/haproxy\/geoip&quot; HAPROXY_FILE=&quot;SNG.txt&quot; #----------------------------------------------------------------------------------------------------------------------- mkdir -p ${TMPDIR} pushd ${TMPDIR} # Download geoip2 lite csv database wget  &quot;https:\/\/download.maxmind.com\/app\/geoip_download?edition_id=GeoLite2-Country-CSV&amp;license_key=${MAXMIND_LICENSE}&amp;suffix=zip&quot; -qO geoip2lite.zip  &amp;&amp; unzip -j geoip2lite.zip if [ $? -gt 0 ]; then  logger -t &quot;haproxy_geoip&quot; &quot;Download not success.&quot;  exit 1 fi  exit for COUNTRY in ${LOCATIONS}; do  echo &quot;# ${COUNTRY}&quot;  COUNTRY_CODE=`cat GeoLite2-Country-Locations-en.csv | grep -i  &quot;${COUNTRY}&quot; | awk -F &quot;,&quot; '{print $1}'`  grep &quot;,${COUNTRY_CODE},&quot; GeoLite2-Country-Blocks-IPv4.csv | awk -F &quot;,&quot;  '{print $1}' done &gt; ${HAPROXY_FILE}  # Check file if [ ! -s ${HAPROXY_FILE} ]; then     logger -t &quot;haproxy_geoip&quot; &quot;File is not exist&quot;     exit 1 fi  if [ -s ${HAPROXY_PATH}\/${HAPROXY_FILE} ]; then     MD5_FILE=`md5sum ${HAPROXY_PATH}\/${HAPROXY_FILE} | awk '{print $1}'` fi  MD5_TMPFILE=`md5sum ${HAPROXY_FILE} | awk '{print $1}'`  if [ &quot;${MD5_TMPFILE}&quot; != &quot;${MD5_FILE}&quot; ]; then  logger -t &quot;haproxy_geoip&quot; &quot;File ${HAPROXY_FILE} is changed&quot;  cp ${HAPROXY_PATH}\/${HAPROXY_FILE}  ${HAPROXY_PATH}\/${HAPROXY_FILE}.backup  mv ${HAPROXY_FILE} ${HAPROXY_PATH}\/${HAPROXY_FILE}  # Test new haprpoxy cfg  \/usr\/sbin\/haproxy -c -f \/etc\/haproxy\/haproxy.cfg  if [ $? -gt 0 ]; then   logger -t &quot;haproxy_geoip&quot; &quot;New file is corrupted, replace by older one from backup.&quot;   mv ${HAPROXY_PATH}\/${HAPROXY_FILE}.backup  ${HAPROXY_PATH}\/${HAPROXY_FILE}  fi fi  popd rm -rf &quot;${TMPDIR}&quot;<\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0435\u0434 \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0437\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u0441\u0435\u043a\u0446\u0438\u044e Variables \u043f\u043e\u0434 \u0432\u0430\u0448\u0438 \u043d\u0443\u0436\u0434\u044b.<\/p>\n<p>  \u0423\u0434\u0430\u0447\u0438!<\/p>\n<p>  <a href=\"https:\/\/mcs.mail.ru\/\"><i>\u041d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0435 Mail.ru Cloud Solutions<\/i><\/a><\/p>\n<p>  <strong>\u0427\u0442\u043e \u0435\u0449\u0435 \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c<\/strong>:\u00a0<\/p>\n<ol>\n<li><a href=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/499594\/\">\u041a\u0430\u043a \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u044c \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0432 HAProxy: \u043f\u043e\u0448\u0430\u0433\u043e\u0432\u0430\u044f \u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f<\/a>.<\/li>\n<li><a href=\"https:\/\/mcs.mail.ru\/blog\/praktiki-rekomendacii-zapusk-kontejnerov-kubernetes\">\u041b\u0443\u0447\u0448\u0438\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0438 \u0438 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0430\u0446\u0438\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 Kubernetes \u0432 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0445 \u0441\u0440\u0435\u0434\u0430\u0445<\/a>.<\/li>\n<li><a href=\"https:\/\/tele.click\/zavtra_oblachno\">\u041d\u0430\u0448 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b \u043e \u0446\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438 IT<\/a>.\u00a0<\/li>\n<\/ol>\n<\/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=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/502168\/\"> https:\/\/habr.com\/ru\/company\/mailru\/blog\/502168\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/company\/mailru\/blog\/502168\/\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/7q\/dg\/dz\/7qdgdzgalavv30lucx95rbufjnw.jpeg\"><br \/>  <a href=\"https:\/\/www.deviantart.com\/augustinasraginskis\/art\/Hello-Planets-818681683\"><i>Hello Planets by Augustinas Raginskis<\/i><\/a><\/p>\n<p>  \u0418\u043d\u043e\u0433\u0434\u0430 \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u0440\u0430\u0444\u0438\u043a\u043e\u043c \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0433\u0435\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u2014 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043b\u043e\u043a\u0430\u0446\u0438\u0439 \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0442\u0440\u0430\u0444\u0438\u043a\u0430 \u043d\u0430 \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0432\u0435\u0440 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043b\u043e\u043a\u0430\u0446\u0438\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0422\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0432\u0435\u0449\u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a GeoIP \u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 <a href=\"https:\/\/www.maxmind.com\/en\/home\">MaxMind<\/a>. \u0412 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0441\u0441\u043a\u0430\u0436\u0443, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.  <\/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-304325","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304325","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=304325"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/304325\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=304325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=304325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=304325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}