Phil
Phil

Reputation: 335

Deploying SSR Nuxt.js on AWS Lambda with Cloudflare?

I am trying to implement a vue.js server(-less) side rendered webshop-a-like-site via nuxt.js on AWS Lambda backed with Cloudflare.

I prefer Cloudflare over Cloudfront because of http/3, image optimization features, safety against attacks, brotli and some more features that Cloudflare provides out-of-the-box.

Unfortunately i couldn't find any ressources if anyone did this before and what to take care of to work properly.

Right now my setup is like:

User -> Route53 -> AWS API Gateway -> AWS Lambda
 -> S3 (for static files)
 -> another AWS Lambda for dynamic data from Elasticsearch indexes

I am not sure where to properly integrate Cloudflare.

`I found a blogposts and threads about:

  1. using Cloudflare Workers instead of AWS API Gateway https://news.ycombinator.com/item?id=16747420
  2. Creating a CNAME for Lambda provided by Cloudfront, but I am not sure if this triggers another Roundtrip to Cloudfront and additional cost? https://forums.aws.amazon.com/thread.jspa?threadID=261297
  3. Connecting a Subdomain to API-Gateway https://medium.com/@bobthomas295/combining-aws-serverless-with-cloudflare-sub-domains-338a1b7b2bd
  4. Another solution could be that I build the nuxt.js directly in a Cloudflare Worker, but I am not sure of any downsides of this solution, since CPU time is very limited in Pro Plan? `

Furthermore I've read an article about the need of securing the API-Gateway against attackers by only allowing Cloudflare IPs.

Did anyone of you already setup Vue + Nuxt with Cloudflare ? Am open to any other suggestions or ideas.

Thanks a lot! Philipp

Upvotes: 1

Views: 1695

Answers (1)

Erik Tate
Erik Tate

Reputation: 161

I am not sure where to properly integrate Cloudflare.

Assuming this is the crux of the question here, this is what it might look like using the notation you provided.

User -> Route53 -> Cloudflare -> AWS API Gateway -> AWS Lambda -> S3 -> Another lambda

The basic idea is that you'll want Cloudflare to be the first thing your DNS (Route53) resolves to so it can properly serve cached content before it ever reaches your application. Which, in this case, would start at API Gateway.

Upvotes: 1

Related Questions