Getting 404 for S3 static website JS behind Apache proxy

人盡茶涼 提交于 2019-12-11 15:45:10

问题


I have an Apache HTTP Server acting as a proxy in front an AWS S3 static website. So http://example.com/testsite goes to the S3 site, but should keep being seen as being accessed from http://example.com/testsite.

The initial index.html access results in a 200 response, however, all the JavaScript files that get run, return 404. They are located in the S3 root, same as index.html, but they end up being accessed as http://example.com/ instead of http://example.com/testsite, hence why I am getting 404.

I am hoping someone can help me with my Apache config snippet (see below, please), so that I can get the correct configuration.

RedirectMatch permanent ^/$ /doorman/
Redirect /js/ /frontman/js/
...
...
<Location /testsite >
  ProxyPreserveHost On
  AuthType openid-connect
  Require valid-user
  ProxyPass <%= @s3_website %>/
  ProxyPassReverse <%= @s3_website %>/
</Location>

回答1:


I resolved this by using the configuration below:

``` ProxyPreserveHost Off AuthType openid-connect Require valid-user ProxyPass <%= @s3_website %> ProxyPassReverse <%= @s3_website %>

ProxyPreserveHost Off AuthType openid-connect Require valid-user ProxyPass <%= @s3_website %>/assets/$1 ProxyPassReverse <%= @s3_website %>/assets/$1

ProxyPreserveHost Off AuthType openid-connect Require valid-user ProxyPass <%= @s3_website %> ProxyPassReverse <%= @s3_website %> ```

Key pieces are:

"ProxyPreserveHost Off" - My S3 bucket name is different from the proxy so this needs to be "Off".

"LocationMatch " - Required so the proxy can match, and map the URL requests and to the S3 bucket location/object.



来源:https://stackoverflow.com/questions/52065809/getting-404-for-s3-static-website-js-behind-apache-proxy

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