{"id":320277,"date":"2021-02-05T11:38:18","date_gmt":"2021-02-05T03:38:18","guid":{"rendered":"http:\/\/4563.org\/?p=320277"},"modified":"2021-02-05T11:38:18","modified_gmt":"2021-02-05T03:38:18","slug":"nginx-%e4%b8%8b%e5%9c%a8%e6%9c%89-cdn-%e7%9a%84%e6%83%85%e5%86%b5%e4%b8%8b%ef%bc%8c%e7%a6%81%e6%ad%a2-ip-%e6%ae%b5-%e7%94%a8%e6%88%b7%e8%ae%bf%e9%97%ae","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=320277","title":{"rendered":"nginx \u4e0b\u5728\u6709 CDN \u7684\u60c5\u51b5\u4e0b\uff0c\u7981\u6b62 ip \u6bb5 \u7528\u6237\u8bbf\u95ee"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  nginx \u4e0b\u5728\u6709 CDN \u7684\u60c5\u51b5\u4e0b\uff0c\u7981\u6b62 ip \u6bb5 \u7528\u6237\u8bbf\u95ee               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : marchDu <\/span>  <span><i><\/i> 6<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6700\u8fd1\u7f51\u7ad9\u7ecf\u5e38\u88ab\u56fd\u5916\u7684\u4e9a\u9a6c\u900a\u7684\u670d\u52a1\u5668\u7684\u722c\u53d6\u5185\u5bb9\uff0c\u73b0\u5728\u5df2\u7ecf\u6709\u9ed1\u540d\u5355\u7684 Ip \u6bb5\uff0c \u4f46\u662f\u7f51\u7ad9\u524d\u7aef\u914d\u6709 CDN,\u5bfc\u81f4 nginx \u7684 $remote_addr \u83b7\u53d6\u7684\u662f ip \u5730\u5740\u662f cdn \u7684 ip deny \u4e0d\u751f\u6548\uff0c<\/p>\n<p>\u627e\u4e86\u4e00\u4e2a\u6559\u7a0b [Nginx \u7f51\u7ad9\u4f7f\u7528 CDN \u4e4b\u540e\u7981\u6b62\u7528\u6237\u771f\u5b9e IP \u8bbf\u95ee\u7684\u65b9\u6cd5]\uff08 https:\/\/zhangge.net\/5096.html)<\/p>\n<p>\u53ea\u80fd\u5b9e\u73b0\u5355\u4e2a ip \u7684\u7981\u6b62\u8bbf\u95ee\uff0c\u8bf7\u95ee\u5927\u5bb6\u6709\u6309\u7167 ip \u6bb5\u7981\u6b62\u8bbf\u95ee\u7684\u529e\u6cd5\u6216\u601d\u8def\u5417\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>14<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5064558\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : superrichman <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             niginx if \u6761\u4ef6 \u6b63\u5219\u8868\u8fbe\u5f0f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064559\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : chendy <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3a\u5565\u4e0d\u5728 cdn \u914d\u9ed1\u540d\u5355\u5462                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064560\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : engineercj <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             ipset add black                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064561\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lewinlan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             cdn \u5e94\u8be5\u53ef\u4ee5\u914d\u7f6e\u8fd4\u56de real ip                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064562\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : huangzxx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1 \u3001nginx real_ip \u6a21\u5757<br \/>2 \u3001\u62ff\u5230\u5382\u5546 cdn \u7684 IP \u6bb5\uff0c\u4f8b\u5982 cloudflare https:\/\/www.cloudflare.com\/ips-v4                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064563\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : privil <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528 openresty \u8fd9\u79cd\u9700\u6c42\u4e5f\u662f\u968f\u4fbf\u505a\u5427\uff0c\u83b7\u53d6 X-Forwarded-For \u7b2c\u4e00\u4e2a\u53d8\u91cf\uff0c\u7136\u540e\u5339\u914d\uff0cban \u6389\u3002\u90fd\u6709\u73b0\u6210\u5f00\u53d1\u597d\u7684\u811a\u672c\u5427\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064564\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Aliencn <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6709 CDN\uff0c\u597d\u591a\u8bf7\u6c42\u90fd\u4e0d\u4f1a\u56de\u6e90\u7ad9\u4e86\uff0c\u5728\u6e90\u7ad9\u4e0a\u914d\u7f6e\u7981\u7528\u89c4\u5219\u6709\u5565\u7528                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064565\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dndx <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6309\u7167 CDN \u5382\u5546\u7684\u5efa\u8bae\u914d\u7f6e\u5c31\u884c\uff0c\u6bd4\u5982 Cloudflare\uff1a<\/p>\n<p>https:\/\/support.cloudflare.com\/hc\/en-us\/articles\/200170786-Restoring-original-visitor-IPs-logging-visitor-IP-addresses<\/p>\n<p>\u7528\u6b63\u5219\u662f\u6709\u70b9\u592a\u571f\u4e86\u3002http:\/\/nginx.org\/en\/docs\/http\/ngx_http_realip_module.html \u4e13\u95e8\u5e72\u8fd9\u4e2a\u7684\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064566\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : laozhoubuluo <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd9\u79cd\u5efa\u8bae\u4e09\u6b65\u8d70:<\/p>\n<p>1. CDN \u4e0a\u914d\u7f6e\u722c\u866b\u9ed1\u540d\u5355 IP \u5730\u5740.<br \/>2. \u6e90\u7ad9\u57fa\u4e8e ngx_http_realip_module \u914d\u7f6e\u89c4\u5219, \u53ea\u4fe1\u4efb CDN \u63d0\u4f9b\u7684 XFF \u5934.<br \/>3. \u6e90\u7ad9\u5728 2 \u751f\u6548\u7684\u57fa\u7840\u4e0a, \u914d\u7f6e\u722c\u866b\u9ed1\u540d\u5355 IP \u5730\u5740, \u6216\u914d\u7f6e\u4ec5\u5141\u8bb8 CDN IP \u8bbf\u95ee.                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064567\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : colordog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @laozhoubuluo \u6d3b\u6349\u8001\u5468\uff0c\u54c8\u54c8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064568\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : colordog <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @laozhoubuluo \u8d76\u5feb\u7ed9\u6211\u641e\u4e0b\u70fd\u706b\u65b0\u6b3e\u4e07\u5146\u5149\u732b\u7684 sip \u8bdd\u673a\u5bc6\u7801                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064569\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : fengjianxinghun <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             set_real_ip_from x.x.x.x;<br \/> real_ip_header X-Forwarded-For;<br \/> real_ip_recursive on;                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064570\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : cco <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7528\u8fc7\u51e0\u6b3e CDN\uff0c\u90fd\u5e26 WAF \u529f\u80fd\u7684- -\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5064571\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : indev <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             Nginx \u652f\u6301 IP \u6bb5\u7684\u5427\uff0c\u53ef\u4ee5\u53ea\u5141\u8bb8\u6765\u81ea CDN IP \u7684\u8bbf\u95ee\uff1a https:\/\/frankindev.com\/2020\/11\/18\/allow-cloudflare-only-in-nginx\/                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>nginx \u4e0b\u5728\u6709 CDN \u7684\u60c5\u51b5&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/320277"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=320277"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/320277\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=320277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=320277"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=320277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}