{"id":233002,"date":"2023-12-25T20:51:24","date_gmt":"2023-12-25T12:51:24","guid":{"rendered":"https:\/\/www.idc.net\/help\/233002\/"},"modified":"2023-12-25T20:51:24","modified_gmt":"2023-12-25T12:51:24","slug":"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_http%e8%bf%9b%e8%a1%8chttp%e4%bb%a3%e7%90%86","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/233002\/","title":{"rendered":"Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_proxy_http\u8fdb\u884cHTTP\u4ee3\u7406"},"content":{"rendered":"<p><title id=\"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_http%e8%bf%9b%e8%a1%8chttp%e4%bb%a3%e7%90%86-ajtnKnxZXB\">Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_proxy_http\u8fdb\u884cHTTP\u4ee3\u7406<\/title><\/p>\n<h1 id=\"apache%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5%ef%bc%9a%e4%bd%bf%e7%94%a8mod_proxy_http%e8%bf%9b%e8%a1%8chttp%e4%bb%a3%e7%90%86-ajtnKnxZXB\">Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_proxy_http\u8fdb\u884cHTTP\u4ee3\u7406<\/h1>\n<h2 id=\"%e4%bb%8b%e7%bb%8d-ajtnKnxZXB\">\u4ecb\u7ecd<\/h2>\n<p>Apache\u662f\u4e00\u79cd\u6d41\u884c\u7684\u5f00\u6e90Web\u670d\u52a1\u5668\u8f6f\u4ef6\uff0c\u5b83\u53ef\u4ee5\u7528\u4e8e\u642d\u5efa\u548c\u7ba1\u7406\u7f51\u7ad9\u3002\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u53ef\u80fd\u9700\u8981\u4f7f\u7528Apache\u4f5c\u4e3aHTTP\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u4ee5\u4fbf\u5728\u5ba2\u6237\u7aef\u548c\u76ee\u6807\u670d\u52a1\u5668\u4e4b\u95f4\u8fdb\u884c\u8bf7\u6c42\u548c\u54cd\u5e94\u7684\u8f6c\u53d1\u3002\u5728\u672c\u6587\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528Apache\u7684mod_proxy_http\u6a21\u5757\u6765\u5b9e\u73b0HTTP\u4ee3\u7406\uff0c\u5e76\u63a2\u8ba8\u4e00\u4e9b\u76f8\u5173\u7684\u5b89\u5168\u7b56\u7565\u3002<\/p>\n<h2 id=\"%e9%85%8d%e7%bd%aeapache%e4%bd%9c%e4%b8%bahttp%e4%bb%a3%e7%90%86-ajtnKnxZXB\">\u914d\u7f6eApache\u4f5c\u4e3aHTTP\u4ee3\u7406<\/h2>\n<p>\u8981\u914d\u7f6eApache\u4f5c\u4e3aHTTP\u4ee3\u7406\uff0c\u6211\u4eec\u9700\u8981\u542f\u7528mod_proxy\u548cmod_proxy_http\u6a21\u5757\u3002\u5728Apache\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u627e\u5230\u4ee5\u4e0b\u4e24\u884c\u5e76\u53d6\u6d88\u6ce8\u91ca\uff1a<\/p>\n<pre><code>LoadModule proxy_module modules\/mod_proxy.so\nLoadModule proxy_http_module modules\/mod_proxy_http.so\n<\/code><\/pre>\n<p>\u4fdd\u5b58\u5e76\u91cd\u65b0\u542f\u52a8Apache\u670d\u52a1\u5668\uff0c\u4f7f\u914d\u7f6e\u751f\u6548\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u9700\u8981\u914d\u7f6e\u4ee3\u7406\u89c4\u5219\u3002\u5728Apache\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code>&lt;VirtualHost *:80&gt;\n    ServerName proxy.example.com\n    ProxyPass \/ http:\/\/target.example.com\/\n    ProxyPassReverse \/ http:\/\/target.example.com\/\n&lt;\/VirtualHost&gt;\n<\/code><\/pre>\n<p>\u5728\u4e0a\u8ff0\u914d\u7f6e\u4e2d\uff0c\u6211\u4eec\u5c06\u6240\u6709\u6765\u81eaproxy.example.com\u7684\u8bf7\u6c42\u8f6c\u53d1\u5230target.example.com\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<h2 id=\"%e5%ae%89%e5%85%a8%e7%ad%96%e7%95%a5-ajtnKnxZXB\">\u5b89\u5168\u7b56\u7565<\/h2>\n<p>\u4f7f\u7528Apache\u4f5c\u4e3aHTTP\u4ee3\u7406\u65f6\uff0c\u6211\u4eec\u9700\u8981\u6ce8\u610f\u4e00\u4e9b\u5b89\u5168\u7b56\u7565\uff0c\u4ee5\u786e\u4fdd\u4ee3\u7406\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002<\/p>\n<h3 id=\"%e9%99%90%e5%88%b6%e8%ae%bf%e9%97%ae-ajtnKnxZXB\">\u9650\u5236\u8bbf\u95ee<\/h3>\n<p>\u4e3a\u4e86\u9632\u6b62\u672a\u7ecf\u6388\u6743\u7684\u8bbf\u95ee\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528Apache\u7684\u8bbf\u95ee\u63a7\u5236\u529f\u80fd\u6765\u9650\u5236\u4ee3\u7406\u670d\u52a1\u5668\u7684\u8bbf\u95ee\u3002\u5728Apache\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code>&lt;Proxy *&gt;\n    Order deny,allow\n    Deny from all\n    Allow from 192.168.0.0\/24\n&lt;\/Proxy&gt;\n<\/code><\/pre>\n<p>\u4e0a\u8ff0\u914d\u7f6e\u5c06\u53ea\u5141\u8bb8\u6765\u81ea192.168.0.0\/24\u7f51\u6bb5\u7684\u8bf7\u6c42\u8bbf\u95ee\u4ee3\u7406\u670d\u52a1\u5668\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u9700\u6c42\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<h3 id=\"%e6%97%a5%e5%bf%97%e8%ae%b0%e5%bd%95-ajtnKnxZXB\">\u65e5\u5fd7\u8bb0\u5f55<\/h3>\n<p>\u4e3a\u4e86\u8ffd\u8e2a\u548c\u76d1\u63a7\u4ee3\u7406\u670d\u52a1\u5668\u7684\u6d3b\u52a8\uff0c\u6211\u4eec\u53ef\u4ee5\u542f\u7528Apache\u7684\u65e5\u5fd7\u8bb0\u5f55\u529f\u80fd\u3002\u5728Apache\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<pre><code>CustomLog \/var\/log\/apache2\/proxy.log common\n<\/code><\/pre>\n<p>\u4e0a\u8ff0\u914d\u7f6e\u5c06\u4ee3\u7406\u670d\u52a1\u5668\u7684\u65e5\u5fd7\u8bb0\u5f55\u5230\/var\/log\/apache2\/proxy.log\u6587\u4ef6\u4e2d\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<h3 id=\"ssl%e5%8a%a0%e5%af%86-ajtnKnxZXB\">SSL\u52a0\u5bc6<\/h3>\n<p>\u5982\u679c\u4f60\u7684\u4ee3\u7406\u670d\u52a1\u5668\u9700\u8981\u5904\u7406\u654f\u611f\u4fe1\u606f\uff0c\u5982\u7528\u6237\u51ed\u636e\u6216\u4fe1\u7528\u5361\u4fe1\u606f\uff0c\u6211\u4eec\u5f3a\u70c8\u5efa\u8bae\u4f7f\u7528SSL\u52a0\u5bc6\u6765\u4fdd\u62a4\u6570\u636e\u4f20\u8f93\u7684\u5b89\u5168\u6027\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528Apache\u7684mod_ssl\u6a21\u5757\u6765\u542f\u7528SSL\u52a0\u5bc6\u3002<\/p>\n<pre><code>LoadModule ssl_module modules\/mod_ssl.so\n<\/code><\/pre>\n<p>\u542f\u7528mod_ssl\u6a21\u5757\u540e\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6eSSL\u8bc1\u4e66\u548c\u5bc6\u94a5\uff0c\u5e76\u5c06HTTPS\u4ee3\u7406\u89c4\u5219\u6dfb\u52a0\u5230Apache\u7684\u914d\u7f6e\u6587\u4ef6\u4e2d\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-ajtnKnxZXB\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4f7f\u7528Apache\u7684mod_proxy_http\u6a21\u5757\uff0c\u6211\u4eec\u53ef\u4ee5\u8f7b\u677e\u5730\u5c06Apache\u914d\u7f6e\u4e3aHTTP\u4ee3\u7406\u670d\u52a1\u5668\u3002\u7136\u800c\uff0c\u5728\u914d\u7f6e\u4ee3\u7406\u670d\u52a1\u5668\u65f6\uff0c\u6211\u4eec\u5fc5\u987b\u6ce8\u610f\u5b89\u5168\u7b56\u7565\uff0c\u4ee5\u786e\u4fdd\u4ee3\u7406\u670d\u52a1\u5668\u7684\u5b89\u5168\u6027\u3002\u9650\u5236\u8bbf\u95ee\u3001\u65e5\u5fd7\u8bb0\u5f55\u548cSSL\u52a0\u5bc6\u662f\u4fdd\u62a4\u4ee3\u7406\u670d\u52a1\u5668\u7684\u91cd\u8981\u63aa\u65bd\u3002<\/p>\n<p>\u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u53ef\u9760\u7684\u9999\u6e2f\u670d\u52a1\u5668\u4f9b\u5e94\u5546\uff0c\u540e\u6d6a\u4e91\u662f\u4f60\u7684\u9996\u9009\u3002\u4ed6\u4eec\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u5e94\u7528\u573a\u666f\u3002\u4f60\u53ef\u4ee5\u5728<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\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_proxy_http\u8fdb\u884cHTTP\u4ee3\u7406 Apache\u5b89\u5168\u7b56\u7565\uff1a\u4f7f\u7528mod_pr [&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-233002","post","type-post","status-publish","format-standard","hentry","category-apache"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/233002","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=233002"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/233002\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=233002"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=233002"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=233002"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}