[英]Setting up mod_proxy_html on CentOS 7
我正在嘗試在我的Web服務器上進行一些測試,以確保反向代理在正常運行之前能夠按預期工作,但是我遇到了mod_proxy和mod_proxy_html的一些問題。
我有2個虛擬主機,其中1個位於端口80上,而1個位於端口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>
我的/ var / www / html / test有2個文件index.html和test.html
test.html的內容是:
<HTML>
<BODY>
<a href="http://127.0.0.1:8080/index.html">TEST</a>
</BODY>
</HTML>
可以成功訪問www.example.com/path/並重定向到www.example.com/path/test.html,但是頁面上的鏈接仍指向127.0.0.1。
httpd -M確實報告正在加載proxy_module和proxy_html_module
我也嘗試過手動將LoadModule添加到http.conf
LoadModule proxy_module /usr/lib64/httpd/modules/mod_proxy.so
LoadModule proxy_html_module /usr/lib64/httpd/modules/mod_proxy_html.so
有什么想法為什么它不能正常工作? 我配置不正確嗎?
CentOS 7中的mod_proxy_html
軟件包不包括任何默認的ProxyHTMLLinks
或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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.