0

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 Answer 1

0

I resolved this by using the configuration below:

  <LocationMatch /*.js >
    ProxyPreserveHost Off
    AuthType openid-connect
    Require valid-user
    ProxyPass <%= @s3_website %>
    ProxyPassReverse <%= @s3_website %>
  </LocationMatch>

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

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

Key pieces are:

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

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.