问题
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