Apache does reverse proxy server

Source: Internet
Author: User

Apache do reverse proxy serverThe Apache agent is divided into forward proxy and reverse proxy: 1 forward Proxy: The client cannot access the external Web directly, it needs to set up a proxy server in the network where the client resides, and the client accesses the external Web through the proxy server (the proxy server needs to be provisioned in the client's browser) for: The proxy server for the ① LAN (typically a gateway, Equivalent to the general usage of squid) ② access to a restricted network proxy server, such as education network access to some foreign sites need to find an agent 2 Reverse Proxy: The client can access the external Web, but cannot access the target Web, a machine within the target web is acting as the proxy for the target Web, and the client directly accesses the proxy just like the target Web (this agent is transparent to the client, that is, the client does not have to do how to set it, and the actual access is only the proxy , thought to be the target of the visit) applies to: ①IDC of a target machine only open the Web, external clients to access, let another machine to do proxy, external direct access to proxy is equivalent to access to target ②IDC target machine of a special Web service run on an abnormal port such as 9000 , and the firewall is only open to 80, at this time can be done on 80 proxy mapping to 9000, external access 80 is equivalent to 9000 simple as in this example, the machine 192.168.0.114 is our reverse proxy serverapache/ 2.0.63 runs a virtual host with two domain names on its port 80 www.a.orgwww.b.org the effect is that access www.a.org is equivalent to accessing another machine 192.168.0.115 access www.b.org That is equivalent to access to the native 9000 port Apache proxy function is implemented by its proxy module. There are two ways to load modules: static and dynamic, which are described separately: a static loadstatic loading, compile the Apache when compiling, compile parameters as follows:
" ./configure "  "-prefix=/usr/local/apache3" "--enable-so"  "--enable-rewrite"  "--with-mpm= Prefork ""--enable-proxy "\ (this parameter is the proxy module enabled)

View Module list/usr/local/apache3/bin/httpd-l display after installation is complete
inch Modules:core.cmod_access.cmod_auth.cmod_include.cmod_log_config.cmod_env.cmod_setenvif.cmod_proxy.cproxy_ Connect.cproxy_ftp.cproxy_http.cprefork.chttp_core.c
....... Edit the configuration file httpd.conf in the Virtual host section
Namevirtualhost *: the<virtualhost *: the>ServerAdmin [email protected]-host.example.comServerName www.a.orgProxyRequests Off<proxy *>Order Deny,allowallow from All</Proxy>Proxypass/http://192.168.0.115/Proxypassreverse/http://192.168.0.115/</VirtualHost> <virtualhost *: the>ServerAdmin [email protected]-host.example.comServerName www.b.orgProxyRequests Off<proxy *>Order Deny,allowallow from All</Proxy>Proxypass/http://127.0.0.1:9000/Proxypassreverse/http://127.0.0.1:9000/</VirtualHost>
two dynamic loadingDynamic loading: Compiled into an already installed Apache (compiled to the DSO module) already installed Apache in/usr/local/apache2 into the Apache source code module directory to compile
CD httpd-2.0. /modules/proxy//usr/local/apache2/bin/apxs-c-i-a mod_proxy.c proxy_connect.c proxy_http.c proxy_util.c
From the output see Apache modules directory has produced mod_proxy.so, and has been activated in httpd.conf
cd/usr/local/apache2/conf/ls. /modules/saw that there was mod_prxoy.so.
Edit Config file vi httpd.conf modify the following loading module
LoadModule proxy_module modules/mod_proxy.so (This is generated when compilation is activated)LoadModule proxy_http_module modules/mod_ Proxy.so (this sentence is to be added manually)
Part of the virtual host Plus
Namevirtualhost *: the<virtualhost *: the>ServerAdmin [email protected]-host.example.comServerName www.a.orgProxyRequests Off<proxy *>Order Deny,allowallow from All</Proxy>Proxypass/http://192.168.0.115/Proxypassreverse/http://192.168.0.115/</VirtualHost> <virtualhost *: the>ServerAdmin [email protected]-host.example.comServerName www.b.orgProxyRequests Off<proxy *>Order Deny,allowallow from All</Proxy>Proxypass/http://127.0.0.1:9000/Proxypassreverse/http://127.0.0.1:9000/</VirtualHost>
Restart Apache Entry Note: If you do not add LoadModule proxy_http_module modules/mod_proxy.so, the browser page will not open, the page display
forbiddenyou Don ' T has permission to access/on the this server.
Log Acess_log inside the display
192.168. 0.28 --[/jun/: +:+0800]   GET/?sessionid=4293567494722637330&rand=1244014624405&context=0&page=com.otheR. ajaxwhowhatupdate&xrand=1244016991554&wwrandid=1244014624405&wwbugid=  2341&wwtype=view http/1.1"  403 315
Or
192.168. 0.28 --[/jun/: +:+0800]   get/http/1.1"403315
That is, 403 error log error_log inside the display
Geneva ::the-using -inusing LoadModule.

Apache does reverse proxy server

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.