在Apache代理后面获取S3静态网站JS的404

问题描述 投票:0回答:1

我在AWS S3静态网站前面有一个Apache HTTP Server充当代理。所以http://example.com/testsite进入S3网站,但应继续被视为从http://example.com/testsite访问。

最初的index.html访问导致200响应,然而,所有运行的JavaScript文件,返回404.它们位于S3根目录,与index.html相同,但最终被访问为http://example.com/而不是http://example.com/testsite,因此为什么我我得到了404。

我希望有人可以帮助我使用我的Apache配置代码段(请参阅下面的内容),以便我可以获得正确的配置。

RedirectMatch permanent ^/$ /doorman/
Redirect /js/ /frontman/js/
...
...
<Location /testsite >
  ProxyPreserveHost On
  AuthType openid-connect
  Require valid-user
  ProxyPass <%= @s3_website %>/
  ProxyPassReverse <%= @s3_website %>/
</Location>
apache amazon-s3 reverse-proxy httpd.conf
1个回答
0
投票

我通过使用以下配置解决了这个问题:

```ProxyPreserveHost Off AuthType openid-connect需要有效用户ProxyPass <%= @ s3_website%> ProxyPassReverse <%= @ s3_website%>

ProxyPreserveHost Off AuthType openid-connect需要有效用户ProxyPass <%= @ s3_website%> / assets / $ 1 ProxyPassReverse <%= @ s3_website%> / assets / $ 1

ProxyPreserveHost Off AuthType openid-connect需要有效用户ProxyPass <%= @ s3_website%> ProxyPassReverse <%= @ s3_website%>```

关键部分是:

“ProxyPreserveHost Off” - 我的S3存储桶名称与代理不同,因此需要“关闭”。

“LocationMatch” - 必需,以便代理可以匹配,并将URL请求映射到S3存储桶位置/对象。

© www.soinside.com 2019 - 2024. All rights reserved.