通过apache从外部服务器提供内容

Ste*_*son 7 apache .htaccess reverse-proxy

我正在abc.com使用apache作为Web服务器运行我的Web应用程序.

我在SquareSpace上托管了一些静态页面...例如. abc.squarespace.com/landing

我想配置apache以abc.squarespace.com在收到请求时提供内容abc.com/landing

我已经在nginx中使用了proxy_pass和后端作为abc.squarespace.com位置/landing.但我不知道如何在Apache中做到这一点.也没有运气在网上进行研究.

提前致谢.

Elv*_*sky 2

消息正文不能包含带有 的 URL abc.com,因此我将使用example.comexample.squarespace.com

我相信您正在寻找帧转发。为了实现它,请使用以下步骤:

  1. 通过 Web 服务器配置设置适当的 HTTP 标头来允许example.squarespace.com帧转发:example.com

X-Frame-Options: ALLOW-FROM https://example.com/

有关详细说明,请参阅https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options

  1. 验证Apache mod_proxy_http是否已启用example.com

# apachectl -M | grep proxy_http proxy_http_module (shared)

  1. 在 Apache 配置或文件中设置以下重写规则.htaccess以提供以下内容:http://example.squarespace.com/landing

<IfModule proxy_http_module> RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\.)?example\.com$ [NC] RewriteRule ^landing(.*) http://example.squarespace.com/landing [P] </IfModule>

这里的语法与Apache mod_rewrite相同。