為什麼我的 Apache 反向代理在發送回客戶端時無法轉換錨點 HREF 屬性?

為什麼我的 Apache 反向代理在發送回客戶端時無法轉換錨點 HREF 屬性?

我有

# For blog
LoadModule proxy_html_module libexec/mod_proxy_html.so
LoadModule ssl_module libexec/mod_ssl.so
LoadModule xml2enc_module libexec/mod_xml2enc.so
SSLProxyEngine on
ProxyRequests off
ProxyPass /blog https://xxxx.wordpress.com
ProxyPassReverse /blog https://xxxx.wordpress.com
ProxyHTMLEnable On
ProxyHTMLURLMap https://xxxx.wordpress.com /blog
<Location /blog>
  ProxyPassReverse /
  ProxyHTMLEnable On
  ProxyHTMLURLMap / /blog
  RequestHeader    unset  Accept-Encoding
  #LogLevel proxy:debug
</Location>

遵循這些指南:

https://devcenter.heroku.com/articles/custom-php-settings#using-a-custom-application-level-apache-configuration

http://www.apachetutor.org/admin/reverseproxies

https://httpd.apache.org/docs/trunk/mod/mod_proxy.html

當我造訪該網址時http://www.xxxx.com/blog/它不會取代錨鏈接https://xxxx.wordpress.com/2015/09/16/hello-world/與/部落格。

它可以在本地運行,但不能在生產環境中運行。

以下是透過代理程式並顯示在瀏覽器中的 HTML 範例:

<h1 class="entry-title">
  <a href="https://xxxx.wordpress.com/2015/09/16/hello-world/" rel="bookmark">Hello world!</a></h1>

我還使用了不同的部落格主機 (HostGator) 而不是 Wordpress.com,但它仍然無法運作。 (但這並不重要。)

Apache 2.4.16,生產:2.4.10(?)

答案1

回應正文中的連結無法使用代理引用進行更新,除非目標主機中有傳回預期 URL 的功能,否則您需要透過附加編碼明確管理回應正文中的連結。 更多細節..

如果它在開發中工作意味著您在產品中缺少這樣的配置。

相關內容