I have a node.js app that I need to host on namecheap, It also involves file handling. does name cheap provides any thing like s3 bucket where I can store files or do I have to use s3?
If I use s3 and host my app on namecheap, won't it be bad implementation because files are on a separate server than the app and cause longer loading time?
Related
I have a NodeJs/React web app. I use to deploy to one EC2 instance. Is this the correct approach?
I've seen online that one option is to put the frontend in S3 with CloudFront and then the backend in an EC2 instance. In this case does the NodeJs server serve the static files from that bucket? Or how would it work?
Hosting dynamic part of React apps on Compute (I'll prefer ECS+Fargate over EC2) and static on S3 + CloudFront is an efficient way to use AWS Managed services capabilities. Your architecture will be something like this:
client -> CloudFront (cached) -> S3 (static resources)
client -> CloudFront (NOT cached) -> LB -> Compute (EC2 / Fargate / Lambda)
You can manage different paths or routes via CloudFront Behaviour functionality. So root (/index.html) points to your S3. and APIs (/api) can point to the Load Balancer for dynamic content.
The bucket works like a static web hosting.
Since React it's client rendering, and not server rendering, it's a complete different app than your node backend.
The client will recieve the static files from CloudFront/S3, and that files (HTML, JavaScript rendered in the client's machine), will communicate with your API hosted in EC2.
You can host both, frontend and backend in EC2.
Or frontend in S3 or CludFront and the backend in EC2.
It's cheaper if you host your stuff separately, since EC2 has dinamic costs.
Now, if you use a server rendering framework like NextJS or Gatsby, the "static files" and the backend are the same thing, the backend render the static files and send them to the client, in that case you need to host everything in EC2.
Usually is better to host everything in the same server for practicity, specially when there are not dynamic costs.
You can opt for another VPS hosting for your server, it's not related to your question, but I reccomend Hetzner, it's cheaper and better than EC2.
AWS newbie here. I have a web app where the Angular dist package is hosted in an S3 bucket, and the backend is being served on an EC2 instance. I've been following this tutorial, but after completion my project in the S3 bucket still does not connect to my remote node server.
What I understood from that tutorial was that by setting up a CloudFront distribution, it will connect the S3 bucket with the EC2 instance. But if I navigate to the CloudFront domain, it loads the S3 bucket contents but still does not connect to my node server.
When I run the node server locally, it connects successfully and I'm able to read and write to my remote Mongo database. This indicates that:
1) the connection to the remote MongoDB is successful, and
2) the front end (in the S3 bucket) is looking for a local node server instead of the remote one (in the EC2 bucket).
So my question is how do I make it so that my services make calls to the remote server instead?
Firstly S3 only hosts static content. So all your Angular dist files will sit on S3. S3 does not connect to your backend. Your browser will try to make AJAX rest calls to your Node Server.
Second your backend Node server needs to expose its Rest services via an API gateway. Thats the recommended approach. It seems if your app is trying to connect locally because of config error. You need to use the API gateway link in your Angular app.
For a quick test you could expose the port in the Security Group of your EC2 and use the public IP of your EC2 to access the node app before going about setting up API gateway.
Let's say I have a single page application using React/Node, and I want to deploy that application using a content delivery network to improve load performance.
To do that in Amazon Web Services (AWS) I would need to incorporate different services to work together.
I would need to host my bundled static web page files on amazon's S3 bucket. Then I would need to host my Node API on Elastic Beanstalk. Lastly, I would then need to setup a CloudFront distribution and set my origin to my S3 bucket.
It would look something like this:
Now, if I wanted to do the same thing in Firebase, according to this video tutorial, I can simply setup Firebase Hosting which is backed by their own CDN which gives similar improved load times. Firebase hosting can encompass the entire React/Node application without the need for separation or various services like I did in AWS.
My questions are:
How does Firebase hosting encompass dynamic Node Apps with out the need to separate the front and backend or use various other services?
The point of a CDN is to cache files, so it wouldn't be possible to use a CDN on a Node API right or wrong? If right then how is Firebase using Node app in their CDN?
It seems much simpler to setup on Firebase to serve an entire dynamic app on their CDN compared to AWS, would their be any drawbacks to this or is it just a better service?
Firebase Hosting is only for your static frontend code. But there is a way to connect Firebase Hosting and Cloud Functions to serve dynamic content that is pretty easy to setup.
https://firebase.google.com/docs/hosting/functions
You can think of Firebase Hosting a zero-ish config equivalent to the AWS S3/CloudFront section of the diagram.
How to migrate a web from Google cloud hosting to personnel domain ??
As you use the "google-cloud-storage" tag, I am going to assume you are storing your website as static files in a GCS bucket and serving it from bucket.storage.googleapis.com or storage.googleapis.com/bucket.
The easiest options are:
Follow the GCS Static Site instructions to keep the content on GCS and serve it on your domain.
Download the files from https://console.cloud.google.com/storage/browser. Then upload the files to a shared hosting or VPS provider who will then serve the content on your domain.
I have a website that is hosted on amazon's EC2 service, and I need to download all the website files and database(s) locally. How can I do this? Also I don't have an S3 storage with amazon, everything is in a EC2 instance.
First export the database to a file. How you accomplish this will depend entirely on what database engine you are using.
You can optionally bundle everything up using a tar command.
Then connect to the server with an SFTP client and download everything.