apache反向代理路径问题

近日在迁移网站的过程中,通过apache反向代理到另一台服务器。
代理地址形式为 IP:Port/path,首页样式加载不出来。后来通过以下方法成功代理。
目前先做下记录,待日后补充
假设我的网站地址是www.abc.com
要代理的地址为 http://192.168.1.10:6800/test/
apache设置反向代理应该设置为

<Virtualhost *:80>
ServerName  www.abc.com
ProxyPass  /test/    http://192.168.1.10:6800/test/
ProxyPassReverse  /test/  http://192.168.1.10:6800/test/
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.abc.com$
RewriteRule ^/$  http://www.abc.com/test/
</VirtualHost>

如果需要设置网站别名,可以在ServerName 下增加一行

ServerAlias  abc.com

然后去掉这一行

RewriteCond %{HTTP_HOST} ^www.abc.com$

注意:需要apache开启rewrite模块

LoadModule rewrite_module modules/mod_rewrite.so
posted @ 2018-07-30 13:06  光元  阅读(834)  评论(1编辑  收藏  举报