{"id":230167,"date":"2023-12-25T16:01:25","date_gmt":"2023-12-25T08:01:25","guid":{"rendered":"https:\/\/www.idc.net\/help\/230167\/"},"modified":"2023-12-25T16:01:25","modified_gmt":"2023-12-25T08:01:25","slug":"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_remoteip%e8%ae%be%e7%bd%aeapache-2","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/230167\/","title":{"rendered":"Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_remoteip\u8bbe\u7f6eApache"},"content":{"rendered":"<p><title id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_remoteip%e8%ae%be%e7%bd%aeapache-QbUqWZEcmm\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_remoteip\u8bbe\u7f6eApache<\/title><\/p>\n<h1 id=\"apache%e6%96%b0%e6%89%8b%e6%95%99%e7%a8%8b%ef%bc%9a%e4%bd%bf%e7%94%a8mod_remoteip%e8%ae%be%e7%bd%aeapache-QbUqWZEcmm\">Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_remoteip\u8bbe\u7f6eApache<\/h1>\n<p>Apache\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5f00\u6e90Web\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u7528\u4e8e\u5728\u4e92\u8054\u7f51\u4e0a\u6258\u7ba1\u7f51\u7ad9\u548c\u5e94\u7528\u7a0b\u5e8f\u3002\u5b83\u662f\u6700\u5e38\u7528\u7684Web\u670d\u52a1\u5668\u8f6f\u4ef6\u4e4b\u4e00\uff0c\u56e0\u5176\u7a33\u5b9a\u6027\u548c\u7075\u6d3b\u6027\u800c\u53d7\u5230\u5e7f\u6cdb\u7684\u8ba4\u53ef\u548c\u4f7f\u7528\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afmod_remoteip%ef%bc%9f-QbUqWZEcmm\">\u4ec0\u4e48\u662fmod_remoteip\uff1f<\/h2>\n<p>mod_remoteip\u662fApache\u7684\u4e00\u4e2a\u6a21\u5757\uff0c\u7528\u4e8e\u66f4\u6539\u5ba2\u6237\u7aefIP\u5730\u5740\u7684\u663e\u793a\u3002\u5f53\u4f7f\u7528\u4ee3\u7406\u670d\u52a1\u5668\u65f6\uff0c\u5ba2\u6237\u7aef\u7684\u771f\u5b9eIP\u5730\u5740\u53ef\u80fd\u4f1a\u88ab\u9690\u85cf\u6216\u66f4\u6539\u3002mod_remoteip\u6a21\u5757\u53ef\u4ee5\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u786e\u4fddApache\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u7684IP\u5730\u5740\u662f\u5ba2\u6237\u7aef\u7684\u771f\u5b9eIP\u5730\u5740\u3002<\/p>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8mod_remoteip%e8%ae%be%e7%bd%aeapache-QbUqWZEcmm\">\u5982\u4f55\u4f7f\u7528mod_remoteip\u8bbe\u7f6eApache<\/h2>\n<p>\u8981\u4f7f\u7528mod_remoteip\u8bbe\u7f6eApache\uff0c\u60a8\u9700\u8981\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u786e\u4fdd\u60a8\u7684Apache\u670d\u52a1\u5668\u5df2\u5b89\u88c5mod_remoteip\u6a21\u5757\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5\uff0c\u60a8\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u547d\u4ee4\u5b89\u88c5\uff1a<\/li>\n<\/ol>\n<pre><code>sudo apt-get install libapache2-mod-remoteip\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u7f16\u8f91Apache\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4ee5\u542f\u7528mod_remoteip\u6a21\u5757\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u6253\u5f00\u914d\u7f6e\u6587\u4ef6\uff1a<\/li>\n<\/ol>\n<pre><code>sudo nano \/etc\/apache2\/apache2.conf\n<\/code><\/pre>\n<ol start=\"3\">\n<li>\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u627e\u5230\u4ee5\u4e0b\u884c\uff1a<\/li>\n<\/ol>\n<pre><code>#LoadModule remoteip_module modules\/mod_remoteip.so\n<\/code><\/pre>\n<ol start=\"4\">\n<li>\u53d6\u6d88\u6ce8\u91ca\u8be5\u884c\uff0c\u4ee5\u542f\u7528mod_remoteip\u6a21\u5757\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u53d6\u6d88\u6ce8\u91ca\uff1a<\/li>\n<\/ol>\n<pre><code>LoadModule remoteip_module modules\/mod_remoteip.so\n<\/code><\/pre>\n<ol start=\"5\">\n<li>\u4fdd\u5b58\u5e76\u5173\u95ed\u914d\u7f6e\u6587\u4ef6\u3002<\/li>\n<\/ol>\n<ol start=\"6\">\n<li>\u91cd\u65b0\u542f\u52a8Apache\u670d\u52a1\u5668\uff0c\u4ee5\u4f7f\u66f4\u6539\u751f\u6548\uff1a<\/li>\n<\/ol>\n<pre><code>sudo service apache2 restart\n<\/code><\/pre>\n<h2 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a0%81-QbUqWZEcmm\">\u793a\u4f8b\u4ee3\u7801<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u5982\u4f55\u5728Apache\u914d\u7f6e\u6587\u4ef6\u4e2d\u4f7f\u7528mod_remoteip\u6a21\u5757\uff1a<\/p>\n<pre><code>&lt;IfModule mod_remoteip.c&gt;\n  RemoteIPHeader X-Forwarded-For\n  RemoteIPInternalProxy 10.0.0.0\/24\n&lt;\/IfModule&gt;\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u4f7f\u7528\u4e86X-Forwarded-For\u5934\u90e8\u6765\u83b7\u53d6\u5ba2\u6237\u7aef\u7684\u771f\u5b9eIP\u5730\u5740\uff0c\u5e76\u6307\u5b9a\u4e86\u5185\u90e8\u4ee3\u7406\u670d\u52a1\u5668\u7684IP\u5730\u5740\u8303\u56f4\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-QbUqWZEcmm\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4f7f\u7528mod_remoteip\u6a21\u5757\uff0c\u60a8\u53ef\u4ee5\u786e\u4fddApache\u65e5\u5fd7\u4e2d\u8bb0\u5f55\u7684IP\u5730\u5740\u662f\u5ba2\u6237\u7aef\u7684\u771f\u5b9eIP\u5730\u5740\uff0c\u800c\u4e0d\u662f\u4ee3\u7406\u670d\u52a1\u5668\u7684IP\u5730\u5740\u3002\u8fd9\u5bf9\u4e8e\u5206\u6790\u548c\u8ffd\u8e2a\u8bbf\u95ee\u8005\u7684\u6765\u6e90\u975e\u5e38\u6709\u7528\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u53ef\u9760\u7684\u4e91\u8ba1\u7b97\u516c\u53f8\u6765\u6258\u7ba1\u60a8\u7684\u7f51\u7ad9\u6216\u5e94\u7528\u7a0b\u5e8f\uff0c\u540e\u6d6a\u4e91\u662f\u4e00\u4e2a\u4e0d\u9519\u7684\u9009\u62e9\u3002\u4ed6\u4eec\u63d0\u4f9b\u9999\u6e2f\u670d\u52a1\u5668\u3001\u7f8e\u56fd\u670d\u52a1\u5668\u548c\u4e91\u670d\u52a1\u5668\u7b49\u591a\u79cd\u4ea7\u54c1\uff0c\u53ef\u4ee5\u6ee1\u8db3\u4e0d\u540c\u9700\u6c42\u3002\u60a8\u53ef\u4ee5\u8bbf\u95ee<a href=\"https:\/\/idc.net\">\u540e\u6d6a\u4e91\u5b98\u7f51<\/a>\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_remoteip\u8bbe\u7f6eApache Apache\u65b0\u624b\u6559\u7a0b\uff1a\u4f7f\u7528mod_remo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[41],"tags":[],"class_list":["post-230167","post","type-post","status-publish","format-standard","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/230167","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=230167"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/230167\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=230167"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=230167"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=230167"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}