Apache 在CentOS 7上设置mod_proxy_html

Apache 在CentOS 7上设置mod_proxy_html,apache,proxy,httpd.conf,mod-proxy,mod-proxy-html,Apache,Proxy,Httpd.conf,Mod Proxy,Mod Proxy Html,我正在尝试在我的web服务器上进行一些测试,以确保反向代理在将其放到实时环境之前能够按预期工作,但我在使用mod_proxy和mod_proxy_html时遇到了一些问题 我有两个虚拟主机,一个在端口80上,一个在端口8080上。我的目标是让www.example.com/path/的传入请求进入端口80,并将反向代理到端口8080 以下是我的虚拟主机设置: <VirtualHost *:8080> ServerName www.example.com:8080 DocumentRo

我正在尝试在我的web服务器上进行一些测试,以确保反向代理在将其放到实时环境之前能够按预期工作,但我在使用mod_proxy和mod_proxy_html时遇到了一些问题

我有两个虚拟主机,一个在端口80上,一个在端口8080上。我的目标是让www.example.com/path/的传入请求进入端口80,并将反向代理到端口8080

以下是我的虚拟主机设置:

<VirtualHost *:8080>
ServerName www.example.com:8080
DocumentRoot /var/www/html/test
RewriteEngine On
RewriteCond  %{REQUEST_URI}  !^.*test
RewriteRule ^/?(.*) http://127.0.0.1:8080/test.html [R=301,L]
</VirtualHost>

<VirtualHost *:80>
ServerName www.example.com
ProxyHTMLEnable On
ProxyHTMLInterp On
ProxyPreserveHost Off
ProxyPass        /path/ http://127.0.0.1:8080/
ProxyPassReverse /path/ http://127.0.0.1:8080/
ProxyHTMLURLMap http://127.0.0.1:8080/ /path/
</VirtualHost>

有没有想过为什么它不能正常工作?我是否配置不正确?

CentOS 7中的
mod_proxy_html
软件包不包含任何默认的
proxyHTMLinks
ProxyHTMLEvents
设置,因此除非您自己提供这些设置,否则它不会执行任何操作

一种方法是将
/usr/share/doc/httpd-2.4.6/proxy html.conf
复制到
/etc/httpd/conf.d/
中。该文件包含以下设置,这些设置将使工作正常:

ProxyHTMLLinks  a       href
ProxyHTMLLinks  area        href
ProxyHTMLLinks  link        href
ProxyHTMLLinks  img     src longdesc usemap
ProxyHTMLLinks  object      classid codebase data usemap
ProxyHTMLLinks  q       cite
ProxyHTMLLinks  blockquote  cite
ProxyHTMLLinks  ins     cite
ProxyHTMLLinks  del     cite
ProxyHTMLLinks  form        action
ProxyHTMLLinks  input       src usemap
ProxyHTMLLinks  head        profile
ProxyHTMLLinks  base        href
ProxyHTMLLinks  script      src for

ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
                onmouseover onmousemove onmouseout onkeypress \
                onkeydown onkeyup onfocus onblur onload \
                onunload onsubmit onreset onselect onchange
LoadModule proxy_module /usr/lib64/httpd/modules/mod_proxy.so
LoadModule proxy_html_module /usr/lib64/httpd/modules/mod_proxy_html.so
ProxyHTMLLinks  a       href
ProxyHTMLLinks  area        href
ProxyHTMLLinks  link        href
ProxyHTMLLinks  img     src longdesc usemap
ProxyHTMLLinks  object      classid codebase data usemap
ProxyHTMLLinks  q       cite
ProxyHTMLLinks  blockquote  cite
ProxyHTMLLinks  ins     cite
ProxyHTMLLinks  del     cite
ProxyHTMLLinks  form        action
ProxyHTMLLinks  input       src usemap
ProxyHTMLLinks  head        profile
ProxyHTMLLinks  base        href
ProxyHTMLLinks  script      src for

ProxyHTMLEvents onclick ondblclick onmousedown onmouseup \
                onmouseover onmousemove onmouseout onkeypress \
                onkeydown onkeyup onfocus onblur onload \
                onunload onsubmit onreset onselect onchange