如何将 AWS 与 Next.js 结合使用?
我正在寻找一些建议,我正在使用 Next.js 来提供可以频繁更新的静态页面,我的应用程序使用各种渲染:SSG、SSR 和 iSSG(新的增量静态站点生成功能).
I am looking for some advices, I am using Next.js to serve static pages that can be updated frequently, my app uses all kind of rendering : SSG, SSR and iSSG (new Incremental Static Site Generation feature).
我想到的 AWS 架构示例:
Exemple of AWS architecture I thought:
- EC2 用于部署运行 next.js 应用程序的 node.js 服务器
- (如果可能)存储/更新 Next.js 生成的静态页面S3 存储桶中的 SSR/iSSG
- Cloudfront 缓存页面(使用 EC2 或 S3 存储桶,如果它是可能)
您知道我可以根据需要使用的最佳 AWS 架构是什么吗?
Do you know what is the best AWS architecture I could use according to my needs?
也许 AWS Elastic Beanstalk 是解决方案,我正在查看.
Maybe AWS Elastic Beanstalk is the solution, I am taking a look.
Next.js 11 + SST + Lambda@Edge
无服务器部署是在 Next.js 8 中引入的.这使您可以更轻松地将 Next.js 应用程序部署到 AWS Lambda 函数,并利用无服务器架构.以这种方式托管通常要便宜得多,而且速度更快,因为您在 CloudFront CDN 网络后面提供页面.
Next.js 11 + SST + Lambda@Edge
Serverless deployment was introduced in Next.js 8. This makes it easier for you to deploy your Next.js app to AWS Lambda functions, and take advantage of the serverless architecture. It's often much cheaper to host this way, and faster because you are serving the pages behind a CloudFront CDN network.
SST 框架可以帮助您轻松构建 Next.js 应用程序并将其部署到您的 AWS 帐户使用 S3、Lambda@Edge 和 CloudFront 的组合.它还可以帮助您为端点配置自定义域.
The SST framework makes it easy to help build and deploy your Next.js app to your AWS account using a combination of S3, Lambda@Edge and CloudFront. It also helps you configure a custom domain for the endpoint.
这是一个完成设置的示例 - https://serverless-stack.com/examples/how-to-create-a-nextjs-app-with-serverless.html
Here's an example walking through the setup - https://serverless-stack.com/examples/how-to-create-a-nextjs-app-with-serverless.html