位置:首页 » 文章/教程分享 » Apache设置反向代理泛目录的方法

客户浏览器使用http协议访问 ApacheServer 。ApacheServer将请求转发到后端的Tomcat或者其他服务器。我们需要使用Apache的ProxyPass来转发URL后端,需要下面两个模块。


mod_proxy.so

mod_proxy_http.so

我们还需要实现客户端浏览器访问http自动转成https协议,需要下面的模块

mod_rewrite.so

1)编辑/etc/httpd/conf/httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


2)编辑 /etc/httpd/httpd-vhosts.conf,配置二级目录。

ServerName codeinn.net
ServerAlias codeinn.net
ProxyPassMatch ^/erjimulu(.*)$ http://www.codeinn.net/$1
ProxyPassMatch ^/erjimulu(.*)/$ http://www.codeinn.net/$1
ProxyPass /erjimulu http://www.codeinn.net:8080/ 
ProxyPassReverse /erjimulu http://www.codeinn.net:8080/

访问http://www.codeinn.net/erjimulu

转向到http://www.codeinn.net:8080