ProxyHTML to rewrite URL

一世执手 提交于 2019-11-30 06:30:58

问题


I've got 2 apache servers set up. One on port 80 and another on port 8077. I'm wanting to see everything on the server on 8077 via a reverse proxy. At the moment I've got:

ProxyPreserveHost Off
ProxyHTMLInterp On
ProxyPass /translate/ http://www.example.com:8077/
ProxyPassReverse /translate/ http://www.example.com:8077/
ProxyHTMLURLMap / /translate/

This allows me to get to the initial page of the site, but the links to images, css and other pages don't work.

For example the css in the html shows as

/css/style.css

where I actually want it to be

/translate/css/style.css

For it to pick up the file from the 8077 server. What can I do with the current setting to get that to work?


回答1:


Ok, this is what I ended up doing to get it working

ProxyPass /translate/ http://www.example.com:8077/
ProxyPassReverse /translate/ http://www.example.com:8077/

ProxyHTMLURLMap http://www.example.com:8087 /translate/

<Location /translate/>
   ProxyPassReverse /
   SetOutputFilter  proxy-html
   ProxyHTMLURLMap http://www.example.com:8077 /translate/
   ProxyHTMLURLMap / /translate/
   ProxyHTMLURLMap  /translate/ /translate/
   RequestHeader    unset  Accept-Encoding
</Location>

This seems to work well. The ProxyHTMLURLMap http://www.example.com:8077 /translate/ line was only needed to translate some "referrer" based urls that caused some pages to end up trying to serve directly from the 8077 port server.



来源:https://stackoverflow.com/questions/14431090/proxyhtml-to-rewrite-url

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!