{"id":32837,"date":"2023-07-11T21:16:58","date_gmt":"2023-11-03T14:52:39","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/"},"modified":"2024-04-30T13:06:53","modified_gmt":"2024-04-30T05:06:53","slug":"%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/","title":{"rendered":"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09"},"content":{"rendered":"<h1>\u9996\u5148<\/h1>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u4f7f\u7528HAProxy\u5b9e\u73b0\u5197\u4f59\u7684\u6587\u7ae0\uff0c\u4f46\u662f\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4f7f\u7528Nginx\u4f5c\u4e3a\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u60c5\u51b5\u3002<\/p>\n<p>&nbsp;<\/p>\n<h1>\u672c\u6587\u7684\u7ed3\u6784<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/4-0.jpeg\" alt=\"nginx-lb-complete.jpg\" \/><\/div>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">IP Sharing \u304c\u30b5\u30dd\u30fc\u30c8\u3055\u308c\u3066\u3044\u308b Chicago Region \u3092\u5229\u7528<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Linode \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306e Distribution \u306f Ubuntu 22.04 LTS \u3067\u69cb\u6210<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Nginx \u304c\u52d5\u304f\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u30fc\u5c64\u3068 Web \u30b5\u30fc\u30d0\u304c\u52d5\u304f Web \u5c64\u3092\u69cb\u6210<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Nginx \u3092\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u30fc\u3068\u3057\u3066\u69cb\u6210<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">2 \u53f0\u306e Nginx \u30b5\u30fc\u30d0\u30fc\u306e Public IP \u3092IP Sharing\u306b\u3066 Active\/Standby \u69cb\u6210<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Web \u5c64\u306f 2 \u53f0\u69cb\u6210\u3002Web \u5c64\u3082 Nginx \u3067\u69cb\u6210\u3002<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u30fc\u5c64\u3068 Web \u5c64\u306f Private IP \u3067\u63a5\u7d9a<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">Nginx \u30b5\u30fc\u30d0\u30fc\u306f\u8a3c\u660e\u66f8\u3092\u53d6\u5f97\u3057\u3001TLS \u306b\u3066\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u304b\u3089\u901a\u4fe1\u3092\u51e6\u7406<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u8ca0\u8377\u5206\u6563\u65b9\u5f0f\u306f\u30e9\u30a6\u30f3\u30c9\u30ed\u30d3\u30f3\u3001\u304a\u3088\u3073 Nginx \u306e ip_hash \u6a5f\u80fd\u3067\u30d0\u30e9\u30f3\u30b7\u30f3\u30b0 (sticky \u306f\u672a\u4f7f\u7528)<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">\u305d\u308c\u305e\u308c\u306e Linode \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u306b Cloud Firewall \u3092\u9069\u7528<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\n<li style=\"list-style-type: none;\">\n<ul class=\"post-ul\">IP Sharing \u306f lelastic \u3067\u69cb\u6210<\/ul>\n<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<ul class=\"post-ul\">\uff08\u30aa\u30d7\u30b7\u30e7\u30f3\uff09Akamai\u306eWeb Secuirty\/CDN\u30b5\u30fc\u30d3\u30b9(Akamai Connected Cloud)\u3092\u9069\u7528\u306e\u969b\u3001Cloud Firewall \u3078 Site Shield \u306e IP \u30a2\u30c9\u30ec\u30b9\u30ea\u30b9\u30c8\u3092\u9069\u7528<\/ul>\n<h2>\/\u7b49\u7b49\/\u4e3b\u673a<\/h2>\n<pre class=\"post-pre\"><code>XXX.XXX.XXX.1  ord-nginx1 # Loadbalancer 1\r\nXXX.XXX.XXX.2  ord-nginx2 # Loadbalancer 2\r\nXXX.XXX.XXX.119  ord-nginx # Shared IP for Loadbalancer 1\/2\r\n192.XXX.XXX.101\tord-web1  # Web 1 Private IP\r\n192.XXX.XXX.102\tord-web2  # Web 2 Private IP\r\n<\/code><\/pre>\n<h1>\u5171\u4eabIP+.<\/h1>\n<p>IP Sharing \u5728 Akamai \u63d0\u4f9b\u7684\u4e91\u670d\u52a1\u4e2d\u662f\u5b9e\u73b0 IP \u6545\u969c\u5207\u6362\u7684\u91cd\u8981\u529f\u80fd\u3002\u6709\u5173\u8be6\u7ec6\u4fe1\u606f\uff0c\u8bf7\u53c2\u8003\u4e0b\u9762\u7684\u6587\u7ae0\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u7b80\u8a00\u4e4b\uff0c\u5bf9\u4e8ePublic IP\u7684\u6545\u969c\u8f6c\u79fb\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u622a\u81f3\u64b0\u5199\u65f6\u70b9\uff0c\u4e1c\u4eac\uff08Tokyo\uff09\u652f\u6301\u65e7\u7684ARP\u65b9\u5f0f\uff0c\u800c\u5176\u4ed6\u8bb8\u591a\u7ad9\u70b9\u5219\u652f\u6301\u65b0\u7684BGP\u65b9\u5f0f\u3002\u4e1c\u4eac\u5c06\u8ba1\u5212\u8fdb\u884c\u7f51\u7edc\u5347\u7ea7\uff0c\u5e76\u6700\u7ec8\u4f7f\u7528BGP\u65b9\u5f0f\u3002\u8bf7\u53c2\u9605\u4e0b\u65b9\u9875\u9762\u83b7\u53d6\u6bcf\u4e2a\u6570\u636e\u4e2d\u5fc3\u7684\u652f\u6301\u60c5\u51b5\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u672c\u6587\u5c06\u8bf4\u660e\u5982\u4f55\u4f7f\u7528\u652f\u6301BGP\u7684\u6570\u636e\u4e2d\u5fc3\u8fdb\u884c\u6545\u969c\u5207\u6362\u7684\u65b9\u6cd5\u3002<\/p>\n<h1>\u521b\u5efaWeb1<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/15-0.jpeg\" alt=\"create-web1-2.jpg\" \/><\/div>\n<div>\u53ef\u4ee5\u968f\u65f6\u6dfb\u52a0\u79c1\u6709IP\u3002<\/div>\n<p>\u53c2\u7167\u4ee5\u4e0b\u9875\u9762\uff0c\u521b\u5efa\u57fa\u672c\u5e03\u5c40\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u5173\u4e8e\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 Linux \u53d1\u884c\u7248\u5b58\u50a8\u5e93\u4e2d\u63d0\u4f9b\u7684\u9884\u7f16\u8bd1\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0c\u8fd9\u662f\u6700\u7b80\u5355\u7684\u9009\u9879\u3002<\/p>\n<pre class=\"post-pre\"><code>apt install nginx\r\n<\/code><\/pre>\n<div>\u5982\u679c\u8981\u4f7f\u7528\u4f1a\u8bdd\u7c98\u6027(stickey)\u529f\u80fd\uff0c\u8bf7\u4ece\u6e90\u4ee3\u7801\u8fdb\u884c\u7f16\u8bd1\u3002<\/div>\n<pre class=\"post-pre\"><code>ord-nginx1:~# nginx -v\r\nnginx version: nginx\/1.18.0 (Ubuntu)\r\n<\/code><\/pre>\n<p>\u6211\u5c06\u8fdb\u884c\u52a8\u4f5c\u786e\u8ba4\u3002<\/p>\n<pre class=\"post-pre\"><code>ord-nginx1 # curl -I 127.0.0.1\r\nHTTP\/1.1 200 OK\r\nServer: nginx\/1.18.0 (Ubuntu)\r\nDate: Fri, 21 Jul 2023 09:18:32 GMT\r\nContent-Type: text\/html\r\nContent-Length: 612\r\nLast-Modified: Fri, 21 Jul 2023 05:22:40 GMT\r\nConnection: keep-alive\r\nETag: \"64ba1620-264\"\r\nAccept-Ranges: bytes\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/25-0.jpeg\" alt=\"web1-nginx-plain.jpg\" \/><\/div>\n<p>\u914d\u7f6e\u6587\u4ef6\u662f\/etc\/nginx\/nginx.conf\uff0c\u6587\u6863\u6839\u76ee\u5f55\u662f\/var\/www\/html\/\u3002<\/p>\n<h2>TLS\u8bbe\u7f6e<\/h2>\n<p>\u8bf7\u53c2\u8003\u4ee5\u4e0b\u9875\u9762\u4e0a\u5173\u4e8e TLS \u7684\u8bbe\u7f6e\u65b9\u6cd5\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u8fd9\u6b21\u6211\u4eec\u5c06\u6309\u7167\u4ee5\u4e0b\u9875\u9762\u4e0a\u7684\u6b65\u9aa4\u6765\u4f7f\u7528 certbot \u8fdb\u884c\u521b\u5efa\u3002<\/p>\n<p>&nbsp;<\/p>\n<h3>\u5728Linux\u73af\u5883\u4e2d\u5b89\u88c5UFW\u3002<\/h3>\n<p>\u5c06\u6765\u4f7f\u7528\u4e91\u9632\u706b\u5899\u8fdb\u884c\u66f4\u8be6\u7ec6\u7684\u63a7\u5236\uff0c\u4f46\u4e5f\u4f1a\u5728Linux\u5b9e\u4f8b\u5185\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code>sudo apt update\r\nsudo apt install ufw\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo ufw allow ssh\r\nsudo ufw allow http\r\nsudo ufw allow https\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo ufw enable\r\n<\/code><\/pre>\n<h3>\u5b89\u88c5snapd<\/h3>\n<p>\u5b89\u88c5\u5305\u7ba1\u7406\u5668snap\u3002snap\u662f\u7528\u4e8e\u6253\u5305\u7684certbot\u5c06\u5728\u6b64\u4e4b\u540e\u5b89\u88c5\u3002<\/p>\n<pre class=\"post-pre\"><code>apt install snapd\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>snap install core\r\nsnap refresh core\r\n<\/code><\/pre>\n<h3>Certbot\u7684\u5b89\u88c5<\/h3>\n<pre class=\"post-pre\"><code>sudo apt remove certbot\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo snap install --classic certbot\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo ln -s \/snap\/bin\/certbot \/usr\/bin\/certbot\r\n<\/code><\/pre>\n<h3>\u4f7f\u7528 Certbot \u521b\u5efa TLS\/SSL\u8bc1\u4e66<\/h3>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53ef\u4ee5\u81ea\u52a8\u8bbe\u7f6eNginx\u914d\u7f6e\uff0c\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<pre class=\"post-pre\"><code>certbot --nginx\r\n<\/code><\/pre>\n<p>\u9700\u8981\u8f93\u5165\u4e00\u4e9b\u5185\u5bb9\u3002\u4ee5\u4e0b\u662f\u8f93\u5165\u793a\u4f8b\u3002<\/p>\n<pre class=\"post-pre\"><code>ord-nginx1# certbot --nginx\r\nSaving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\r\nEnter email address (used for urgent renewal and security notices)\r\n (Enter 'c' to cancel): {my_account}@foo.com\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nPlease read the Terms of Service at\r\nhttps:\/\/letsencrypt.org\/documents\/LE-SA-v1.3-September-21-2022.pdf. You must\r\nagree in order to register with the ACME server. Do you agree?\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: Y\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nWould you be willing, once your first certificate is successfully issued, to\r\nshare your email address with the Electronic Frontier Foundation, a founding\r\npartner of the Let's Encrypt project and the non-profit organization that\r\ndevelops Certbot? We'd like to send you email about our work encrypting the web,\r\nEFF news, campaigns, and ways to support digital freedom.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: Y\r\nAccount registered.\r\nPlease enter the domain name(s) you would like on your certificate (comma and\/or\r\nspace separated) (Enter 'c' to cancel): nginx-ha.{mydoman_name}\r\nRequesting a certificate for nginx-ha.{mydomain_name}\r\n\r\nSuccessfully received certificate.\r\nCertificate is saved at: \/etc\/letsencrypt\/live\/nginx-ha.{mydomain_name}\/fullchain.pem\r\nKey is saved at:         \/etc\/letsencrypt\/live\/nginx-ha.{mydomain_name}\/privkey.pem\r\nThis certificate expires on 2023-10-19.\r\nThese files will be updated when the certificate renews.\r\nCertbot has set up a scheduled task to automatically renew this certificate in the background.\r\n\r\nDeploying certificate\r\nSuccessfully deployed certificate for nginx-ha.{mydomain_name} to \/etc\/nginx\/sites-enabled\/default\r\nCongratulations! You have successfully enabled HTTPS on https:\/\/nginx-ha.{mydoman_name}\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nIf you like Certbot, please consider supporting our work by:\r\n * Donating to ISRG \/ Let's Encrypt:   https:\/\/letsencrypt.org\/donate\r\n * Donating to EFF:                    https:\/\/eff.org\/donate-le\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \r\n<\/code><\/pre>\n<p>\u6211\u4eec\u6765\u786e\u8ba4\u4e00\u4e0b Let&#8217;s Encrypt \u8bc1\u4e66\u662f\u5982\u4f55\u521b\u5efa\u7684\u3002<\/p>\n<pre class=\"post-pre\"><code>ord-nginx1# cat \/etc\/letsencrypt\/live\/README\r\nThis directory contains your keys and certificates.\r\n\r\n`[cert name]\/privkey.pem`  : the private key for your certificate.\r\n`[cert name]\/fullchain.pem`: the certificate file used in most server software.\r\n`[cert name]\/chain.pem`    : used for OCSP stapling in Nginx &gt;=1.3.7.\r\n`[cert name]\/cert.pem`     : will break many server configurations, and should not be used\r\n                 without reading further documentation (see link below).\r\n\r\nWARNING: DO NOT MOVE OR RENAME THESE FILES!\r\n         Certbot expects these files to remain in this location in order\r\n         to function properly!\r\n\r\nWe recommend not moving these files. For more information, see the Certbot\r\nUser Guide at https:\/\/certbot.eff.org\/docs\/using.html#where-are-my-certificates.\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/52-0.jpeg\" alt=\"nginx-ha-domain.jpg\" \/><\/div>\n<h1>Web2\u7684\u5236\u4f5c<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/54-0.jpeg\" alt=\"create-web2.jpg\" \/><\/div>\n<p>\u4f7f\u7528Linode\u7684\u514b\u9686\u529f\u80fd\u521b\u5efaWeb1\u3002\u521b\u5efa\u540e\uff0c\u66f4\u6539\u4e3b\u673a\u540d\u3002\u4e0d\u9700\u8981\u8fdb\u884c\u5176\u4ed6\u64cd\u4f5c\u3002<\/p>\n<pre class=\"post-pre\"><code>hostnamectl set-hostname ord-web2\r\n<\/code><\/pre>\n<h1>\u521b\u5efaNginx1\uff08\u8d1f\u8f7d\u5747\u8861\uff09<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/58-0.jpeg\" alt=\"create-nginx1-clone.jpg\" \/><\/div>\n<p>\u5047\u8bbe\u6211\u4eec\u5c06\u4f7f\u7528\u5728Web1\u4e0a\u521b\u5efa\u7684\u8bc1\u4e66\u4fe1\u606f\uff0c\u5e76\u901a\u8fc7Linode\u7684\u514b\u9686\u529f\u80fd\u521b\u5efaWeb1\u3002\u6211\u4eec\u4f1a\u66f4\u6539\u4e3b\u673a\u540d\u3002<\/p>\n<div>\u5f53\u5b9e\u4f8b\u7684\u5927\u5c0f\u4e0d\u540c\u65f6\uff0c\u5728\u514b\u9686\u65f6\u8fdb\u884c\u9009\u62e9\u3002<\/div>\n<pre class=\"post-pre\"><code>hostnamectl set-hostname ord-nginx1\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>ord-nginx1# cat \/etc\/nginx\/nginx.conf\r\nuser www-data;\r\nworker_processes auto;\r\npid \/run\/nginx.pid;\r\ninclude \/etc\/nginx\/modules-enabled\/*.conf;\r\n\r\nevents {\r\n\tworker_connections 768;\r\n\t# multi_accept on;\r\n}\r\n\r\nhttp {\r\n\tupstream sample_app {\r\n        ip_hash;                # Forwarding based on an IP address\r\n\t\tserver 192.XXX.XXX.101 max_fails=2 fail_timeout=10s;# ord-web1 Private\r\n\t\tserver 192.XXX.XXX.102 max_fails=2 fail_timeout=10s; # ord-web2 Private\r\n\t}\r\n\tserver {\r\n\t\tserver_name nginx-ha.{mydomain_name};\r\n\t\tlisten 443;\r\n\t\tssl_certificate\t\/etc\/letsencrypt\/live\/nginx-ha.{mydomain_name}\/fullchain.pem;\r\n\t\tssl_certificate_key \/etc\/letsencrypt\/live\/nginx-ha.{mydomain_name}\/privkey.pem;\r\n\t\tlocation \/ {\r\n\t\t\tif_modified_since off;\r\n\t\t\texpires off;\r\n\t\t\tproxy_pass http:\/\/sample_app;\r\n\t\t}\r\n\t}\r\n\r\n\t##\r\n\t# Basic Settings\r\n\t##\r\n\r\n\tsendfile on;\r\n\ttcp_nopush on;\r\n\ttypes_hash_max_size 2048;\r\n\t# server_tokens off;\r\n\r\n\t# server_names_hash_bucket_size 64;\r\n\t# server_name_in_redirect off;\r\n\r\n\tinclude \/etc\/nginx\/mime.types;\r\n\tdefault_type application\/octet-stream;\r\n\r\n\t##\r\n\t# SSL Settings\r\n\t##\r\n\r\n\tssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE\r\n\tssl_prefer_server_ciphers on;\r\n\r\n\t##\r\n\t# Logging Settings\r\n\t##\r\n\r\n\taccess_log \/var\/log\/nginx\/access.log;\r\n\terror_log \/var\/log\/nginx\/error.log;\r\n\r\n\t##\r\n\t# Gzip Settings\r\n\t##\r\n\r\n\tgzip on;\r\n\r\n\t# gzip_vary on;\r\n\t# gzip_proxied any;\r\n\t# gzip_comp_level 6;\r\n\t# gzip_buffers 16 8k;\r\n\t# gzip_http_version 1.1;\r\n\t# gzip_types text\/plain text\/css application\/json application\/javascript text\/xml application\/xml application\/xml+rss text\/javascript;\r\n\r\n\t##\r\n\t# Virtual Host Configs\r\n\t##\r\n\r\n\tinclude \/etc\/nginx\/conf.d\/*.conf;\r\n\tinclude \/etc\/nginx\/sites-enabled\/*;\r\n}\r\n<\/code><\/pre>\n<h1>\u521b\u5efaNginx2\uff08\u8d1f\u8f7d\u5747\u8861\u5668\uff09<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/64-0.jpeg\" alt=\"create-nginx2-clone.jpg\" \/><\/div>\n<p>\u5c06Nginx1\u514b\u9686\u4e3aNginx2\uff0c\u5e76\u66f4\u6539\u4e3b\u673a\u540d\u3002<\/p>\n<pre class=\"post-pre\"><code>hostnamectl set-hostname ord-nginx2\r\n<\/code><\/pre>\n<h1>Nginx1\/Nginx2\u7684\u914d\u7f6e\u8bbe\u7f6e\u3002<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/68-0.jpeg\" alt=\"create-nginx-lb-conf.jpg\" \/><\/div>\n<p>\u786e\u8ba4nginx.conf\u662f\u5426\u6309\u4e0a\u8ff0\u65b9\u5f0f\u8fd0\u4f5c\u3002<\/p>\n<p>\u91cd\u8981\u7684\u662f\u6b63\u78ba\u5730\u5c07\u4e0a\u6e38\u548c\u670d\u52d9\u5668\u95dc\u806f\u8d77\u4f86\u3002\u4e0a\u6e38\u7684\u7c21\u55ae\u8a2d\u7f6e\u5982\u4e0b\uff1a\u5c07\u8acb\u6c42\u5e73\u5747\u5206\u914d\u5230\u5169\u500b\u8f49\u767c\u76ee\u6a19\u4e0a\uff0c\u4e26\u4f7f\u7528\u79c1\u6709 IP \u800c\u4e0d\u662f\u516c\u5171 IP\u3002<\/p>\n<pre class=\"post-pre\"><code>\tupstream sample_app {\r\n\t\tserver 192.XXX.XXX.101 \r\n\t\tserver 192.XXX.XXX.102 \r\n\t}\r\n<\/code><\/pre>\n<p>\u5728\u670d\u52a1\u5668\u4e2d\uff0c\u901a\u8fc7 proxy_pass \u6307\u5b9a\u7684 sample_app \u5b57\u7b26\u4e32\u4e0e upstream \u5b57\u7b26\u4e32\u7684\u8bbe\u7f6e\u548c\u94fe\u63a5\u975e\u5e38\u91cd\u8981\u3002if_modified_since off;\u548c expires off; \u662f\u4e3a\u4e86\u6d4b\u8bd5\u76ee\u7684\u800c\u6dfb\u52a0\u7684\uff0c\u4ee5\u9632\u6b62\u6d4f\u89c8\u5668\u8fdb\u884c\u7f13\u5b58\u3002<\/p>\n<pre class=\"post-pre\"><code>server {\r\n\t\tserver_name nginx-ha.{mydomain_name};\r\n\t\tlisten 443;\r\n\t\tssl_certificate\t\/etc\/letsencrypt\/live\/nginx-ha.{mydomain_name}\/fullchain.pem;\r\n\t\tssl_certificate_key \/etc\/letsencrypt\/live\/nginx-ha.{mydomain_name}\/privkey.pem;\r\n\t\tlocation \/ {\r\n\t\t\tif_modified_since off;\r\n\t\t\texpires off;\r\n            proxy_connect_timeout 10;\r\n\t\t\tproxy_pass http:\/\/sample_app;\r\n\t\t}\r\n\t}\r\n<\/code><\/pre>\n<h1>\u7d22\u5f15\u6587\u4ef6\u7684\u66f4\u6539<\/h1>\n<p>\u4e3a\u4e86\u66f4\u5bb9\u6613\u5730\u786e\u5b9a\u662f\u88ab\u5f15\u5bfc\u5230\u54ea\u4e2a Web \u670d\u52a1\u5668\uff0c\u6211\u4eec\u5c06\u66f4\u6539\u6587\u6863\u6839\u76ee\u5f55\u7684\u7d22\u5f15\u6587\u4ef6\u3002<\/p>\n<h2>\u7f511<\/h2>\n<p>\u7f16\u8f91 \/var\/www\/html\/ \u76ee\u5f55\u4e0b\u7684\u7d22\u5f15\u6587\u4ef6\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/78-0.jpeg\" alt=\"web1-homepage.jpg\" \/><\/div>\n<h2>Web2<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/80-0.jpeg\" alt=\"web2-homepage.jpg\" \/><\/div>\n<h1>\u5171\u4eabIP\u8bbe\u7f6e<\/h1>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/82-0.jpeg\" alt=\"create-ip-sharing.jpg\" \/><\/div>\n<p>\u53c2\u8003\u4ee5\u4e0b\u6587\u7ae0\uff0c\u8fdb\u884cIP\u5171\u4eab\u914d\u7f6e\u3002<\/p>\n<p>&nbsp;<\/p>\n<h2>Lo \u8bbe\u5907\u7684\u9884\u68c0\u786e\u8ba4<\/h2>\n<p>IP\u5171\u4eab\u4f1a\u5728LO\u8bbe\u5907\u4e0a\u8bbe\u7f6e\u4e00\u4e2a\u5171\u4eab\u7684IP\u5730\u5740\u3002\u5148\u786e\u8ba4\u8bbe\u7f6e\u4e4b\u524d\u7684\u72b6\u6001\u3002\u53ea\u6709\u56de\u73af\u5730\u5740\u88ab\u6ce8\u518c\u3002<\/p>\n<h3>Nginx1<\/h3>\n<pre class=\"post-pre\"><code>ord-nginx1 # ip -4 a show dev lo\r\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\r\n    inet 127.0.0.1\/8 scope host lo\r\n       valid_lft forever preferred_lft forever\r\n<\/code><\/pre>\n<h3>Nginx2\u7684\u610f\u601d\u662f\u2026\u2026 (The meaning of Nginx2 is&#8230;)<\/h3>\n<pre class=\"post-pre\"><code>ord-nginx2 # ip -4 a show dev lo\r\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\r\n    inet 127.0.0.1\/8 scope host lo\r\n       valid_lft forever preferred_lft forever\r\n<\/code><\/pre>\n<h2>\u5728 netplan \u7684\u914d\u7f6e\u4e2d\uff0c\u5c06\u5171\u4eab IP \u5206\u914d\u7ed9 lo\u3002<\/h2>\n<pre class=\"post-pre\"><code># This file describes the network interfaces available on your system\r\n# For more information, see netplan(5).\r\nnetwork:\r\n  version: 2\r\n  renderer: networkd\r\n  ethernets:\r\n    eth0:\r\n      dhcp4: yes\r\n    lo:  # \u3053\u3053\u304b\u3089\u8ffd\u52a0\u3057\u307e\u3059\u3002\r\n      match:\r\n        name: lo\r\n      addresses:\r\n        - XXX.XXX.XXX.119\/32 # \/32 \u3092\u8a2d\u5b9a\u3057\u307e\u3059\u3002\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>ord-nginx1 # netplan apply\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>ord-nginx2 # netplan apply\r\n<\/code><\/pre>\n<h2>\u8bf7\u518d\u6b21\u786e\u8ba4lo\u8bbe\u5907\u7684\u8bbe\u7f6e\u3002<\/h2>\n<h3>Nginx1(Nginx1)<\/h3>\n<pre class=\"post-pre\"><code>ord-nginx1 # ip -4 a show dev lo\r\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\r\n    inet 127.0.0.1\/8 scope host lo\r\n       valid_lft forever preferred_lft forever\r\n    inet XXX.XXX.XXX.119\/32 scope global lo\r\n       valid_lft forever preferred_lft forever\r\n<\/code><\/pre>\n<h3>Nginx2<\/h3>\n<pre class=\"post-pre\"><code>ord-nginx2 # ip -4 a show dev lo\r\n1: lo: &lt;LOOPBACK,UP,LOWER_UP&gt; mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000\r\n    inet 127.0.0.1\/8 scope host lo\r\n       valid_lft forever preferred_lft forever\r\n    inet XXX.XXX.XXX.119\/32 scope global lo\r\n       valid_lft forever preferred_lft forever\r\n<\/code><\/pre>\n<h2>\u5f15\u5165Lelastic<\/h2>\n<h3>\u5f39\u6027\u5b89\u88c5<\/h3>\n<pre class=\"post-pre\"><code>version=v0.0.6\r\ncurl -LO https:\/\/github.com\/linode\/lelastic\/releases\/download\/$version\/lelastic.gz\r\ngunzip lelastic.gz\r\nchmod 755 lelastic\r\nsudo mv lelastic \/usr\/local\/bin\/\r\n<\/code><\/pre>\n<h3>\/etc\/systemd\/system\/lelastic.service \u53ef\u4ee5\u7528\u4ee5\u4e0b\u65b9\u5f0f\u8868\u8fbe\uff1a<\/h3>\n<p>\u8acb\u63d0\u4f9b\u4ee5\u4e0b\u8cc7\u8a0a\uff1a\u4ec0\u9ebc\u662f\u60a8\u6240\u9700\u7684\u89e3\u6c7a\u65b9\u6848\uff1f \u6709\u4efb\u4f55\u7279\u5b9a\u8981\u6c42\u55ce\uff1f \u610f\u5716\u548c\u884c\u52d5\u7684\u80cc\u666f\u662f\u4ec0\u9ebc\uff1f \u5728\u53c3\u8207\u89e3\u6c7a\u65b9\u6848\u7684\u904e\u7a0b\u4e2d\uff0c\u60a8\u7684\u89d2\u8272\u548c\u76ee\u6a19\u662f\u4ec0\u9ebc\uff1f<\/p>\n<h4>Nginx1\uff08\u4ee5\u4e3b\u8981\u89d2\u8272\u8fd0\u884c\uff09<\/h4>\n<pre class=\"post-pre\"><code>[Unit]\r\nDescription= Lelastic\r\nAfter=network-online.target\r\nWants=network-online.target\r\n\r\n[Service]\r\nType=simple\r\nExecStart=\/usr\/local\/bin\/lelastic -dcid 18 -primary &amp;\r\nExecReload=\/bin\/kill -s HUP $MAINPID\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<p>\u7531\u4e8e\u6211\u4eec\u4f7f\u7528\u829d\u52a0\u54e5\u7684\u6570\u636e\u4e2d\u5fc3\uff0c\u6240\u4ee5\u6211\u4eec\u5c06\u5176\u8bbe\u7f6e\u4e3a18\u3002<\/p>\n<h4>Nginx2\uff08\u4f5c\u4e3a\u6b21\u8981\u670d\u52a1\u5668\u8fd0\u884c\uff09\u3002<\/h4>\n<pre class=\"post-pre\"><code>[Unit]\r\nDescription= Lelastic\r\nAfter=network-online.target\r\nWants=network-online.target\r\n\r\n[Service]\r\nType=simple\r\nExecStart=\/usr\/local\/bin\/lelastic -dcid 18 -secondary &amp;\r\nExecReload=\/bin\/kill -s HUP $MAINPID\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<h3>\u5171\u540c\u7684\u8bbe\u5b9a<\/h3>\n<pre class=\"post-pre\"><code>sudo chmod 644 \/etc\/systemd\/system\/lelastic.service\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>sudo systemctl start lelastic\r\nsudo systemctl enable lelastic\r\n<\/code><\/pre>\n<h1>Nginx1\/2 \u7684\u7f51\u7edc<\/h1>\n<p>\u8bf7\u786e\u8ba4\u5df2\u7ecf\u6ce8\u518c\u4e86\u79c1\u6709 IP\uff0c\u4ee5\u53ca\u516c\u5171 IP\u3002<\/p>\n<h3>\/etc\/systemd\/network\/05-eth0.network\u53ef\u4ee5\u88ab\u4e2d\u6587\u7ffb\u8bd1\u4e3a\u300c\/etc\/systemd\/network\/05-eth0\u7f51\u7edc\u300d\u3002<\/h3>\n<pre class=\"post-pre\"><code>[Match]\r\nName=eth0\r\n\r\n[Network]\r\nDHCP=no\r\nDNS=172.232.0.15 172.232.0.16 172.232.0.19\r\n\r\nDomains=members.linode.com\r\nIPv6PrivacyExtensions=false\r\n\r\nGateway=XXX.XXX.XXX.1\r\nAddress=XXX.XXX.XXX.11\/24 # Public IP address\r\nAddress=192.YYY.YYY.11\/17 # Private IP address\r\n<\/code><\/pre>\n<h1>\u5728 DNS \u670d\u52a1\u5668\u4e2d\u66f4\u6539 CNAME \u76ee\u6807\u3002<\/h1>\n<p>\u56e0\u4e3a\u5728Web\u5c42\u670d\u52a1\u5668\u4e0a\u83b7\u53d6\u4e86\u8bc1\u4e66\uff0c\u6700\u7ec8\u5c06\u4f1a\u88ab\u5f15\u5bfc\u81f3\u5728\u8d1f\u8f7d\u5747\u8861\u5c42\u8bbe\u7f6e\u7684\u5171\u4eabIP\u3002<\/p>\n<h2>\u4e4b\u524d<\/h2>\n<pre class=\"post-pre\"><code>nginx-ha.{mydomain_name}.\t300\tIN\tCNAME\tXXX-XXX-XXX-1.ip.linodeusercontent.com.\r\nXXX-XXX-XXX-1.ip.linodeusercontent.com. 85996 IN A XXX.XXX.XXX.1\r\n<\/code><\/pre>\n<h2>\u5b8c\u6210<\/h2>\n<pre class=\"post-pre\"><code>nginx-ha.{mydomain_name}.\t300\tIN\tCNAME\tXXX-XXX-XXX-10.ip.linodeusercontent.com.\r\nXXX-XXX-XXX-10.ip.linodeusercontent.com.\t21600 IN A XXX.XXX.XXX.10\r\n<\/code><\/pre>\n<p>\u53ef\u4ee5\u76f4\u63a5\u5728A\u8bb0\u5f55\u4e2d\u6307\u5b9aIP\u5730\u5740\u3002<\/p>\n<h1>\u4e91\u9632\u706b\u5899\u7684\u914d\u7f6e<\/h1>\n<h2>\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u8bbe\u7f6e<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/125-0.jpeg\" alt=\"create-firewall-1.jpg\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/126-0.jpeg\" alt=\"firewall-front-mark.jpg\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/127-0.jpeg\" alt=\"firewall-back-linode.jpg\" \/><\/div>\n<h2>\u7f51\u9875\u8bbe\u7f6e<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/129-0.jpeg\" alt=\"create-firewall-2.jpg\" \/><\/div>\n<p>\u672c\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u8bbe\u7f6e\u53ea\u5141\u8bb8\u901a\u8fc7\u4e24\u4e2a\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u79c1\u6709IP\u3002\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u516c\u5171IP\u5c06\u88ab\u660e\u786e\u4e22\u5f03\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/131-0.jpeg\" alt=\"firewall-lb.jpg\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/132-0.jpeg\" alt=\"firewall-web-linode.jpg\" \/><\/div>\n<h2>\u7f51\u7ad9\u9632\u62a4\u7684\u8bbe\u7f6e\uff08\u9009\u9879\uff09<\/h2>\n<p>\u8fd9\u662f\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u8bbe\u7f6e\u3002<\/p>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/135-0.jpeg\" alt=\"nginx-lb-complete.jpg\" \/><\/div>\n<p>\u5982\u679c\u60a8\u5df2\u7ecf\u5b89\u88c5\u4e86Akamai\u5b89\u5168\u4ea7\u54c1\uff0c\u60a8\u53ef\u4ee5\u5c06\u672c\u6587\u4ecb\u7ecd\u7684\u914d\u7f6e\u89c6\u4e3aAkamai CDN\u7684\u6e90\u7ad9\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6e90\u7ad9\u7684IP\u5c06\u8bbe\u7f6e\u4e3a\u4e4b\u524d\u8bbe\u7f6e\u7684\u5171\u4eabIP\u3002\u901a\u8fc7\u4f7f\u7528Site Shiled\u548cCloud Firewall\uff0c\u60a8\u53ef\u4ee5\u963b\u6b62Akamai\u7f51\u7edc\u4ee5\u5916\u7684\u901a\u4fe1\uff0c\u5e76\u9632\u6b62\u76f4\u63a5\u653b\u51fb\u6e90\u7ad9\u3002\u83b7\u53d6Site Shield\u7684IP\u540e\uff0c\u60a8\u9700\u8981\u5728\u8d1f\u8f7d\u5747\u8861\u5668\u7684Cloud Firewall\u8bbe\u7f6e\u4e2d\u8fdb\u884c\u63a7\u5236\u3002<\/p>\n<h1>\u8003\u8bd5<\/h1>\n<h2>\u505c\u6b62 Web1 \u4e0a\u7684 Nginx\u3002<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/139-0.jpeg\" alt=\"stop-web1.jpg\" \/><\/div>\n<pre class=\"post-pre\"><code>ord-web1# systemctl stop nginx\r\n<\/code><\/pre>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/141-0.jpeg\" alt=\"navigate-web2.jpg\" \/><\/div>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/142-0.jpeg\" alt=\"stop-nginx-web1.jpg\" \/><\/div>\n<p>\u91cd\u65b0\u542f\u52a8 Web1 \u4e0a\u7684 Nginx\u3002<\/p>\n<pre class=\"post-pre\"><code>ord-web1# systemctl start nginx\r\n<\/code><\/pre>\n<p>\u8c37\u6b4c\u6d4f\u89c8\u5668\u5c06\u8fde\u63a5Web1\u3002\u53ea\u8981Web1\u4ecd\u7136\u8fd0\u884c\uff0c\u5c31\u4f1a\u4fdd\u6301\u4e0eWeb1\u7684\u8fde\u63a5\u3002\u8fd9\u662f\u901a\u8fc7nginx.conf\u6587\u4ef6\u4e2d\u7684ip_hash\u8bbe\u7f6e\u6765\u5b9e\u73b0\u7684\uff0c\u8be5\u8bbe\u7f6e\u6839\u636e\u5ba2\u6237\u7aef\u7684IP\u8fdb\u884c\u8d1f\u8f7d\u5747\u8861\u3002\u5982\u679c\u7981\u7528\u6b64\u8bbe\u7f6e\uff0c\u5219\u6bcf\u6b21\u4f1a\u4ee5\u8f6e\u8be2\u65b9\u5f0f\u4ea4\u66ff\u663e\u793aWeb1\/Web2\u7d22\u5f15\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5c06\u5173\u95edWeb1\u670d\u52a1\u5668\u3002\u5f53proxy_connect_timeout\u8bbe\u7f6e\u4e3a10\u79d2\u8d85\u65f6\u540e\uff0c\u5c06\u91cd\u5b9a\u5411\u5230Web2\u3002proxy_connect_timeout\u7684\u9ed8\u8ba4\u503c\u4e3a60\u79d2\uff0c\u6240\u4ee5\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\uff0c\u5c06\u7b49\u5f851\u5206\u949f\u3002<\/p>\n<p>\u6211\u5c06\u542f\u52a8Web1\u7684\u670d\u52a1\u5668\u3002<\/p>\n<p>\u5728Chinese\uff0c\u6211\u5c06\u5bf9\u4ee5\u4e0b\u53e5\u5b50\u8fdb\u884c\u7ffb\u8bd1\uff1a\u5728Web1\/Web2\u4e0a\u663e\u793a\u8bbf\u95ee\u65e5\u5fd7\u3002<\/p>\n<pre class=\"post-pre\"><code>tail -f \/var\/log\/nginx\/access.log\r\n<\/code><\/pre>\n<p>\u5728\u65e5\u5fd7\u4e2d\u53d1\u73b0\u4e86\u6765\u81eaNginx1\u7684\u79c1\u6709IP\u8bbf\u95ee\u3002<\/p>\n<pre class=\"post-pre\"><code>192.XXX.XXX.101 - - [24\/Jul\/2023:12:34:41 +0000] \"GET \/ HTTP\/1.0\" 200 629 \"-\" \"Mozilla\/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit\/605.1.15 (KHTML, like Gecko) Version\/13.0.3 Mobile\/15E148 Safari\/604.1\"\r\n<\/code><\/pre>\n<h2>\u505c\u6b62 Nginx1<\/h2>\n<div><img decoding=\"async\" class=\"post-images\" title=\"\" src=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/153-0.jpeg\" alt=\"stop-lb-nginx1.jpg\" \/><\/div>\n<p>\u5728\u8fd9\u79cd\u72b6\u6001\u4e0b\uff0c\u5c06\u8d1f\u8f7d\u5747\u8861\u5668 Nginx1 \u5173\u95ed\u7535\u6e90\u3002<\/p>\n<p>\u786e\u8ba4\u4e0b\u7ebf\u540e\uff0c\u518d\u6b21\u901a\u8fc7Chrome\u6d4f\u89c8\u5668\u8bbf\u95ee\u3002\u65e5\u5fd7\u663e\u793a\u6709\u6765\u81eaNginx2\u7684\u79c1\u6709IP\u7684\u8bbf\u95ee\u3002<\/p>\n<pre class=\"post-pre\"><code>192.XXX.XXX.102 - - [24\/Jul\/2023:12:35:36 +0000] \"GET \/ HTTP\/1.0\" 200 629 \"-\" \"Mozilla\/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit\/605.1.15 (KHTML, like Gecko) Version\/13.0.3 Mobile\/15E148 Safari\/604.1\"\r\n<\/code><\/pre>\n<p>\u5982\u679c\u6210\u529f\u542f\u52a8\u5e76\u4e14\u6b63\u5e38\u8fd0\u884c\uff0c\u90a3\u4e48\u6d4b\u8bd5\u5c31\u7ed3\u675f\u4e86\u3002<\/p>\n<h1>\u603b\u7ed3<\/h1>\n<p>\u6211\u5df2\u89e3\u91cb\u5728 Linode \u5be6\u4f8b\u4e4b\u524d\u914d\u7f6e Nginx \u4f5c\u70ba\u8ca0\u8f09\u5e73\u8861\u5668\uff0c\u4e26\u4f7f\u7528 IP \u5171\u4eab\u5be6\u73fe\u5197\u9918\u3002\u540c\u6642\uff0c\u6211\u9084\u4ecb\u7d39\u4e86 Cloud Firewall \u7684\u8a2d\u7f6e\u793a\u4f8b\uff0c\u4ee5\u4fbf\u5728\u4f7f\u7528 Akamai \u5b89\u5168\u7522\u54c1\u7684\u60c5\u6cc1\u4e0b\u63a1\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u9996\u5148 \u672c\u6587\u4ecb\u7ecd\u4e86\u4f7f\u7528HAProxy\u5b9e\u73b0\u5197\u4f59\u7684\u6587\u7ae0\uff0c\u4f46\u662f\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4f7f\u7528Nginx\u4f5c\u4e3a\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u60c5 [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-32837","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx\u548cip\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08akamai\uff09\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09\" \/>\n<meta property=\"og:description\" content=\"\u9996\u5148 \u672c\u6587\u4ecb\u7ecd\u4e86\u4f7f\u7528HAProxy\u5b9e\u73b0\u5197\u4f59\u7684\u6587\u7ae0\uff0c\u4f46\u662f\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4f7f\u7528Nginx\u4f5c\u4e3a\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u60c5 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx\u548cip\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08akamai\uff09\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-11-03T14:52:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-30T05:06:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/4-0.jpeg\" \/>\n<meta name=\"author\" content=\"\u5b87, \u534e\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u5b87, \u534e\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/\",\"name\":\"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-11-03T14:52:39+00:00\",\"dateModified\":\"2024-04-30T05:06:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458\",\"name\":\"\u5b87, \u534e\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g\",\"caption\":\"\u5b87, \u534e\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx\u548cip\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08akamai\uff09\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09","og_description":"\u9996\u5148 \u672c\u6587\u4ecb\u7ecd\u4e86\u4f7f\u7528HAProxy\u5b9e\u73b0\u5197\u4f59\u7684\u6587\u7ae0\uff0c\u4f46\u662f\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u4f7f\u7528Nginx\u4f5c\u4e3a\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\u7684\u60c5 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/\u4f7f\u7528nginx\u548cip\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08akamai\uff09\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-11-03T14:52:39+00:00","article_modified_time":"2024-04-30T05:06:53+00:00","og_image":[{"url":"https:\/\/cdn.silicloud.com\/blog-img\/blog\/img\/657d13ab37434c4406bf9359\/4-0.jpeg"}],"author":"\u5b87, \u534e","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u5b87, \u534e","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/","name":"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-11-03T14:52:39+00:00","dateModified":"2024-04-30T05:06:53+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528Nginx\u548cIP\u5171\u4eab\u521b\u5efa\u5197\u4f59\u8d1f\u8f7d\u5747\u8861\u5668\uff08Akamai\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/513018e4e121d3add1b7c5de8be21458","name":"\u5b87, \u534e","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/63cd45cbc05a35fc4ff7637a163c83c4962ef58d27472726c3a3e0c9c5194f0f?s=96&d=mm&r=g","caption":"\u5b87, \u534e"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/yuhua\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/%e4%bd%bf%e7%94%a8nginx%e5%92%8cip%e5%85%b1%e4%ba%ab%e5%88%9b%e5%bb%ba%e5%86%97%e4%bd%99%e8%b4%9f%e8%bd%bd%e5%9d%87%e8%a1%a1%e5%99%a8%ef%bc%88akamai%ef%bc%89%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32837","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=32837"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32837\/revisions"}],"predecessor-version":[{"id":92087,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/32837\/revisions\/92087"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=32837"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=32837"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=32837"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}