1

I have a web architecture using Apache as front-end and Nodejs as back-end. I want to migrate this architecture to AWS. Node.js is going to be an Elastic Beanstalk and Apache will be stored on Amazon S3 (it stores only static files).

I use these directives to map the /api URL path to the back-end in Apache :

<Location /api>
    ProxyPass http://localhost:8081/api
</Location>

I would like to use the same mechanism in AWS. I found out that Amazon S3 is not going to be able to do this since it is only a storage service.

I found out that Amazon CloudFront can use multiples Amazon CloudFront Origins that can be Amazon S3 buckets or Amazon Elastic Load Balancers. Then, I would use an Amazon EC2 to host my Node.js application back-end with an Amazon Load Balancer

The final architecture would then be

                        - Amazon Elastic Load Balancer -> Amazon EC2
                 /api  /
                      /
-->Amazon CloudFront-<
                      \
                 else  \
                        - Amazon S3

Does this type of architecture is possible ? If yes, is it the best way to achieve this kind of architecture in AWS ?

Thanks everybody for your responses !

3

Yes... use CloudFront.

Its official purpose, of course, is as a caching CDN, but it has the built-in ability to selectively route requests to the appropriate origin system, based on the path.

So, you'd configure your default path to be S3, and requests would be sent to your bucket. Configure a second origin pointing to the Elastic Load Balancer in front of your Elastic Beanstalk deployment. Set a path pattern of /api/* to route requests to this second origin.

The caching behavior can be disabled if not needed or desired.

A CloudFront deployment is referred to as a "distribution."

http://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web.html

Is this the "best" approach? It depends on your expertise and creativity... but if you desire to use the available AWS components, then yes, this is probably the way to go. It is the only component that provides essentially maintenance-free routing of requests by path on http. (Amazon API gateway also routes on paths, of course, but it's not a fit for this application with S3 as the "wildcard" destination.)

1
  • Tranks for your answer ! We'll try this (; – Eric Ly Sep 24 '15 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.