since the problem is still there I though I throw in another solution.
My case was that I wanted to auto deploy all pull requests to s3 for testing before merge making them accessible on [mydomain]/pull-requests/[pr number]/[mydomain]/pull-requests/[pr number]/
(ex. www.example.com/pull-requests/822/www.example.com/pull-requests/822/)
To the best of my knowledge non of s3 rules scenarios would allow to have multiple projects in one bucket using html5HTML5 routing so while above most voted suggestion works for a project in root folder, it doesn't for multiple projects in own subfolders.
So I pointed my domain to my server where following nginxNginx config did the job
location /pull-requests/ {
try_files $uri @get_files;
}
location @get_files {
rewrite ^\/pull-requests\/(.*) /$1 break;
proxy_pass http://<your-amazon-bucket-url>;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @get_routes;
}
location @get_routes {
rewrite ^\/(\w+)\/(.+) /$1/ break;
proxy_pass http://<your-amazon-bucket-url>;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @not_found;
}
location @not_found {
return 404;
}
it tries to get the file and if not found assumes it is html5HTML5 route and tries that. If you have a 404 angular page for not found routes you will never get to @not_found and get you angular 404 page returned instead of not found files, which could be fixed with some if rule in @get_routes@get_routes or something.
I have to say I don't feel too comfortable in area of nginxNginx config and using regex for that matter, I got this working with some trial and error so while this works I am sure there is room for improvement and please do share your thoughts.
Note: remove s3 redirection rules if you had them in S3 config.
and btwBTW works in Safari