1、安装proxy模块
[root@localhost modules]# cd /usr/local/src/httpd-2.2.16 [root@localhost httpd-2.2.16]# cd modules [root@localhost modules]# ls aaa config5.m4 debug filters ldap Makefile.in NWGNUmakefile ssl arch database echo generators loggers mappers proxy test cache dav experimental http Makefile metadata README [root@localhost modules]# cd proxy/ [root@localhost proxy]# ls ajp.h Makefile mod_proxy.dsp NWGNUproxy ajp_header.c Makefile.in mod_proxy_ftp.c NWGNUproxyajp ajp_header.h mod_proxy_ajp.c mod_proxy_ftp.dsp NWGNUproxybalancer ajp_link.c mod_proxy_ajp.dsp mod_proxy.h NWGNUproxycon ajp_msg.c mod_proxy_balancer.c mod_proxy_http.c NWGNUproxyftp ajp_utils.c mod_proxy_balancer.dsp mod_proxy_http.dsp NWGNUproxyhtp CHANGES mod_proxy.c mod_proxy_scgi.c NWGNUproxyscgi config.m4 mod_proxy_connect.c modules.mk proxy_util.c libproxy.exp mod_proxy_connect.dsp NWGNUmakefile [root@localhost proxy]# /usr/local/apache2/bin/apxs -c -i -a mod_proxy.c mod_proxy_connect.c mod_proxy_http.c proxy_util.c //安装所需要的模块 [root@localhost proxy]# ls /usr/local/apache2/modules/ httpd.exp mod_deflate.so mod_headers.so mod_rewrite.so libphp5.so mod_expires.so mod_proxy.so mod_status.so [root@localhost proxy]# vim /usr/local/apache2/conf/httpd.conf LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy.so //手动添加这一条 [root@localhost proxy]# /usr/local/apache2/bin/apachectl -t Syntax OK
2、修改配置文件
<VirtualHost *:80> ServerName www.test.com CustomLog "/dev/null" combined ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://www.test.com/ ProxyPassReverse / 192.168.13.111/ </VirtualHost>
[root@localhost proxy]# vim /etc/hosts 192.168.13.111 www.test.com