Recently encountered a project, need to access a unit of intranet server, the other side required to configure a front-mounted machine to forward all the Web requests, and then learned a reverse proxy , looked up some information, also completed the HelloWorld example.
About the reverse proxy introduction, you can refer to the introduction of 1 and the introduction of 2 mutual supplement it, about the concept of the introduction is very good.
I am now just completing the first step, which is to configure the forwarding request.
Operating system is CentOS, about Linux installation Apache doesn't say much.
After the Apache installation is complete, go to the/etc/httpd/conf directory and open the httpd.conf file
And then
- 1. First check whether the agent module is turned on
- 2. Configure the most basic reverse proxy
- 3. Restart Apache
The first step
Take a look
LoadModule proxy_module modules/mod_proxy.soLoadModule proxy_connect_module modules/mod_proxy_connect.soLoadModule proxy_ftp_module modules/mod_proxy_ftp.soLoadModule proxy_http_module modules/mod_proxy_http.so
Open, if not open, remove the # in front of the above code
Step Two
Open the httpd.conf in the/etc/httpd/conf directory and add the following code at the end
<VirtualHost 123.123.123.123:8800>ServerName exampleServerAlias exampleProxyRequestsoff<Proxy *> Order allow,deny Allowall</Proxy>ProxyPass / http://www.baidu.com/ProxyPassReverse / http://www.baidu.com/</VirtualHost>
Simply say these parameters
- 123.123.123.123 is the IP address used by the server
- 8800 is the port that Apache listens on
- The "http://www.baidu.com/" behind Proxypass and Proxypassreverse is a true destination server that requires our request, and the spaces +/+ spaces in front of it are part of our configuration.
Step Three
Restart Apache, enter the/etc/init.d/directory, execute./HTTPD restart
This way, when we enter HTTP://123.123.123.123:8800/in the client browser, the page will return to the homepage of Baidu, when we visit http://123.123.123.123:8800/admin/index.html, Should return http://www.baidu.com/search/error.html because the path we're accessing doesn't exist.
The above is the most basic use of Apache to configure proxy forwarding requests
More detailed configuration can be seen in a more detailed blog
Such as:
Apache Configure forward Proxy vs. reverse proxy
Ubuntu Configuration Reverse Proxy
Linux Apache Configuration Reverse Proxy