Getting REACT App running on port 3001 to show on AWS EC2 Http port 80 - node.js

I deployed a REACT application on an AWS EC2 running Ubuntu by cloning my github repository and installing node and npm. I tried running the application after installing all of the dependencies and it finally says:
Project is running at http://localhost:3001/
How do I make the running project show up on the http(80) port of the EC2?
Inbound ports open: 80, 443 and 22.

Please install nginx on your EC2 instance which will serve your frontend.
Follow the below blog for steps
https://dev.to/xarala221/the-easiest-way-to-deploy-a-react-web-application-2l8a
Thanks

Related

Create open 80 port for Storybook for React

Original port for my Storybook installation was port 8080 and 6006 see documentation enter link description here, and figured to change the JSON file to point to port 80
This is the package.json file part of my Storybook installation:
Now I've assigned a domain name since port 80 is hosted under the public ip, the problem is after a while that port closes and we can't see the Storybook because the port is closed again. How do I configure so that the port stays open? I'm using Jelastic as a web hosting environment: https://jelastic.com/
My current configuration is as followed:
Running a VPS with Ubuntu 18.04 installed
Other dependencies:
NPM
Yarn
NodeJS
Create React App : https://reactjs.org/docs/create-a-new-react-app.html
StoryBook for React : https://storybook.js.org/docs/react/get-started/introduction
Chromatic : https://www.chromatic.com/
Storybook's webserver is not meant to be exposed to the internet, it's only for local development. You can create a static build of your Storybook using yarn build-storybook and upload that to any hosting provider. However, since you're using Chromatic, you don't have to, because it gives you free hosting out of the box. See https://www.chromatic.com/docs/document#direct-access-to-your-storybook for details.

Application stops after configuring nginx (docker) for https

I have followed this tutorial for deploying docker containers on AWS EC2 instance:
https://www.digitalocean.com/community/tutorials/how-to-secure-a-containerized-node-js-application-with-nginx-let-s-encrypt-and-docker-compose
and after reaching step 5 (where nginx is configured for HTTPS), the application just stops working. Here's my application: www.alphadevop.co
Here’s my nginx configuration:
https://github.com/cyrilcabo/alphadevelopment/blob/master/nginx-conf/nginx.conf
And here’s my docker-compose.yml:
https://github.com/cyrilcabo/alphadevelopment/blob/master/docker-compose.yml
[Here's the webserver logs][1]
[1]: https://i.stack.imgur.com/oawtD.png
Silly mistake, port 443 wasn't allowed on my application. I was confused because when i checked on my server, port 443 was open. Then I checked here, https://www.yougetsignal.com/tools/open-ports/ , saying it was closed. I then found out that there's an inbound rule for AWS EC2 instance top allow port 443.
Credits here: NGINX SSL Timeout

Dockerized Node on AWS Elastic Beanstalk. Error 502 BadGateway

I have a Node app (Isomorphic React app) dockerized and deployed to AWS Elastic Beanstalk. I have all the information below but if you want a tldr: How do you configure port forwarding between a host and a container in AWS Elastic Beanstalk i.e. 5000:3000?
I want my application to work like this (the numbers are ports):
End User --80--> EC2 Instance / Nginx --5000--> Container --3000--> Application
I used the Dockerfile to EXPOSE 5000. I know that it's just a suggestion but as far as I know Amazon uses it to expose ports in the docker container instead of a docker-compose.yml. The app runs on port 3000. Code in the node to run on port 3000:
process.env.PORT || 3000
When trying to access the site using port 80, I'm getting a 502 Bad Gateway error.
I SSHed into the EC2 instance hosting my docker container. The nginx config for elasticbeanstalk looks like this:
upstream docker {
server [CONTAINER_IP]:5000;
keepalive 256;
}
The IP is the correct IP of the container (I checked by using Docker Inspect). When I run: sudo docker ps -a
I get:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
REDACTED REDACTED "node server.js" 34 hours ago Up 34 hours 5000/tcp jolly_williams
If I run netstat on the EC2 host instance I see that port 80 is open:
tcp 0 0 0.0.0.0:80
When I look at the logs on the EC2 host instance I see this error multiple times for different resources:
request: "GET / HTTP/1.1", upstream: "http://[CONTAINER_IP]:5000/", host: [Beanstalk URL] connection refused
Now here is the kicker, it works when I run:
sudo curl [ContainerIP]:3000 (from the EC2 host intance)
-or-
sudo docker exec -ti [CONTAINER_NAME] curl http://localhost:3000
Anyone know why the node is running off 3000 and not 5000? What can I do?
Talked to AWS Support. They're saying that the docker port has to be the same port the application is listening on i.e. no port mapping

How to expose my angular 4 to internet using ngrok?

i have an angular app running on localhost with port 80, when i use ngrok http 80 command it shows invalid host header. how to use ngrok to work with my angular 4?
if your local angular webapp runs at port 80, run:
ngrok http --host-header=rewrite 80
Note: ngrok should be added to your PATH
I have managed to to solve this by running my angular app like this ng serve --disable-host-check this should work for you

how to install a node.js server at chat.mydomain.com on a hostgator vps hosting?

I have a hostgator VPS hosting account.
I already have a site at my main domain, say mydomain.com
now i want to install node.js server for chat.mydomain.com.
i need some help installing the node.js server.
what i m looking for is, How to setup the node.js server? - I can download and install the node v 0.4.6 but how to make it listen to a port say chat.mydomain.com:8088 like apache? That is install the "node" as a service and listen to port 8088 like apache listens to port 80?
Thanks,
Anjan
All you need to is to open up a port to listen to requests e.g. if you want to run Node on 8088 and then access it with chat.mydomain.com.
According to their support, you need to contact them to open up 8088 for you > http://support.hostgator.com/articles/pre-sales-policies/open-new-ports

Resources