Home >Operation and Maintenance >Apache >Can Apache do reverse proxy?
The reverse proxy (Reverse Proxy) method refers to using a proxy server to accept connection requests on the Internet, then forwarding the request to the server on the internal network, and returning the results obtained from the server to the person requesting the connection on the Internet. client, at this time the proxy server appears as a reverse proxy server to the outside world.
#Mainly talks about Apache’s reverse proxy.
First make sure that Apache has these modules. Confirm that these modules are present in the Apache root directory. They mainly include the following modules:
mod_proxy.so
mod_proxy_ajp.so
mod_proxy_balancer.so
mod_proxy_connect.so
mod_proxy_http.so
Open the configuration conf/httpd.conf file and add these modules Remove the comments, as shown in the figure below:
Modify the configuration file, open the file conf/httpd.conf, and add the following configuration at the end of the file:
#反向代理 ProxyRequests Off ProxyPass /clusterDemo http://127.0.0.1:8081/clusterDemo ProxyPassReverse /clusterDemo http://127.0.0.1:8081/clusterDemo ProxyPass /clusterDemo2 http://127.0.0.1:8082/clusterDemo2 ProxyPassReverse /clusterDemo2 http://127.0.0.1:8082/clusterDemo2 ProxyPass /clusterDemo3 http://127.0.0.1:8083/clusterDemo3 ProxyPassReverse /clusterDemo3 http://127.0.0.1:8083/clusterDemo3 #8888为apache的监听端口 <proxy> AllowOverride None Order Deny,Allow Allow from all </proxy>
Test
Start apache and the corresponding tomcat.
Enter the address on the browser: http://127.0.0.1:8888/clusterDemo/index.jsp
Enter the address on the browser: http://127.0.0.1:8888/clusterDemo2/index.jsp
#The requested application in the address bar can be accessed correctly, indicating that Apache's reverse proxy request is forwarded successfully! ! !
For more Apache related technical articles, please visit the Apache usage tutorial column to learn!
The above is the detailed content of Can Apache do reverse proxy?. For more information, please follow other related articles on the PHP Chinese website!