I am new to node.js and running web app on EC2 ubuntu, right now, my team have complete vue.js front end project, and I have complete node.js express MYSQL backend, and I have tested the connection and set up of server-side API (node.js MYSQL) by pulling from our git back-end branch. The front end has already been tested locally by listening to public IP address. while hosting server-side on EC2, now it is time to upload the front-end project (which is in the front-end branch) on EC2 to host the front end project. and now I have 2 problems:
should we merge back-end and front-end branches together to the main? and then clone main? I have already cloned our project but in back-end branch on git. would that conflict?
If running both projects on EC2 ubuntu, should API listening on PORT above 4000 (which is I believe not publicly accessible?) like 8080? should it listen to localhost or public IP address?
This is my first SE project with my team. We have researched so many online resources but we still get lost, thank you so much!
CodePudding user response:
- should we merge back-end and front-end branches together to the main? and then clone main? I have already cloned our project but in back-end branch on git. would that conflict?
Why would you want to do any of that? Git just organizes your code, it doesn't dictate how the code is deployed.
- If running both projects on EC2 ubuntu, should API listening on PORT above 4000 (which is I believe not publicly accessible?) like 8080?
By default, no ports on AWS are public at all. You have to open the ports you want to open in the EC2 security group. Running the backend on port 8080 would be fine, if you open that port on the security group.
should it listen to localhost or public IP address?
The Vue application runs in every user's web browser, so it can't listen to localhost
. The public IP on AWS is NATed, so it probably can't listen to that either. Generally this type of service would listen to 0.0.0.0
.
Note that none of this so far is secure, for example there is no SSL so all communication between the front-end and back-end is in the open. None of this is fault tolerant, your single server goes down your entire system is down. None of this is scaleable, if you start getting a lot of traffic you have no way of adding more servers to handle the load.
I suggest looking into using AWS Elastic Beanstalk to deploy your application for you. It will give you ways to easily add load balancing, auto-scaling, and an SSL certificate.