AWS s3 / React:密码保护网站
我有一个 React 应用程序已成功部署到 S3 存储桶。我需要找到一种方法来密码保护对 s3 url 的访问,例如,如果您在浏览器中打开该 url,某种弹出窗口会在继续操作之前要求输入用户名/密码。有人推荐我 .htaccess 和 .htpasswd ?
是否有更好的解决方案,即使用 Cloudfront?我无法阻止除 1 个 IP 地址之外的所有访问,因为需要多个 IP 地址来访问该站点。
任何建议将不胜感激。感谢
Stack:
用于路由的 React router... s3 用于托管/Cloudfront 用于 CDN... 用于数据库的Firestore... 谷歌验证器用于身份验证
I have a react application deployed successfully to a S3 bucket. I need to find a way to password protect access to the s3 url, for example if you open the url in your browser some kind of popup asks for username/password before progressing. I was recommended .htaccess and .htpasswd ?
IS there a better solution, i.e using Cloudfront? I am unable to block all access, except to 1 ip address, as multiple IP addresses need to access the site.
Any suggestions would be greatly appreciated. Thanks
Stack:
React router for routing...
s3 for hosting/Cloudfront for CDN...
Firestore for DB...
google authenticator for auth
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
AWS Amplify 将成为您最好的朋友。 AWS 的这份指南清楚地解释了如何完成这一切。还有其他指南可以帮助指导您使用 AWS Amplify 托管 S3 存储桶。
https://docs.aws.amazon.com/amplify/最新/userguide/access-control.html
AWS Amplify will be your best friend here. This guide from AWS clearly explains how to do it all. There area other guides out there that will help guide you though using AWS Amplify to host your S3 bucket.
https://docs.aws.amazon.com/amplify/latest/userguide/access-control.html