How to deploy NodeJS Server app using AWS EC2 public IP? - node.js

I'm using NodeJS and Express.js to run my projects.
In local app preview mode, everything works fine. But the ugly, long, and temporary preview link provided on each preview just doesn't cut it for me and I want someone to be able to access my server via:
HTTP://<MY-ELASTIC-IP>:8080
I followed the guide here:
AWS Cloud9 App preview guide
and have my Elastic IP allocated and associated to my EC2 instance running our Cloud9 IDE, I set the inbound security rules as follows:
Inbound rules of my security group for the EC2 instance running our Cloud9 IDE
Then in my NodeJS app I set the listening port to 8080 (as instructed by the guide), and tried all kinds of listening IP addresses (127.0.0.1, 0.0.0.0, (MY-ELASTIC-IP), (MY-PRIVATE-IP)) and tried running the app, hoping I can finally access my server through , but none of them worked.
I'm a seasoned roomie server developer and most of my deployments were through Supervisor, Nginx, Certbot , DNS configuration through my domain registration site, and some router port forwarding and boom my servers would be online in less than 10 minutes.
But really ... what is up with AWS. There's just so much stuff they shoved into this new Cloud9 (I miss the old c9...) and I can't get even the basic stuff done.
What am I missing here? Is there some sort of port forwarding I have to configure between my public elastic IP and my private IPs? I visited most of the similar questions posted about this and still couldn't manage to get my public URL to point to the running NodeJS instance inside C9.

I fought with this forever and finally got access by using listening address '0.0.0.0' and constructed the url using the IPv4 Public IP listed in "Manage EC2 Instance": HTTP://:8080
Not ideal because this Public IP changes each time I launch the environment but solved my immediate problem

Related

Deploy Node js app to local windows machine

I created a Node.js app (firebase-admin) that reads/writes data from our local SQL Server, reads/writes data to Firebase Realtime Database. This part is working now. My other desktop apps will connect to this Node.js app to request data from firebase RTDB. This part is also working.
I would like now to host the Node.js app in our LAN. How do I setup the host machine so that the desktop apps (also from the same LAN) will connect like http://local ip of host machine/name of app. Example, http://192.168.1.254/firebasemiddleware/. Also, if I have another app, let's say named anothermiddleware, the local address should be, http://192.168.1.254/anothermiddleware/.
This machine is behind a firewall and will not be visible from outside the LAN.
How can I do this?
Thank you.
You could run Nginx as a reverse proxy to pass through based on address to your
multiple local services.
You would setup a reverse proxy on Nginx like this:
location /firebasemiddleware {
proxy_pass http://localhost:3000;
}
location /anothermiddleware {
proxy_pass http://localhost:3001;
}
The docs on this are here
If you're new to this there is a really cool configuration generator by digital ocean that might make life easier for you located here
Your network is currently a local area network and you cannot allow external connections to access it.
Option 1: you find out about the nat of the current carrier that is providing you and open the corresponding port of the nodejs app you are running with nat's port and access it through the public ip, get the public ip by accessing some websites for example: https://whatismyipaddress.com/en-vn/index.
Option 2: simpler if you don't have a static ipv4 address or can't open nat of your carrier, then you can use tunnel, recommend to learn https://www.cloudflare.com/products/tunnel/ .

Node app accessible inside aws server but not outside

I am able to access my app inside the ec2 instance using elinks but when I try to do from the browser it says "This site can’t be reached".
I am trying to run a node app on port 3000
my netstat
netstat
my ec2 security group inbound rules
after going through other stackoverflow tickets I figured that there are two levels of checks
EC2 security groups
EC2 instance firewall
so although I added the port 3000 on security group inbound rules still I had to puncture the instance firewall as well. Port 80 is open by default
I'm actually doing the same thing, and in order to do so, you need to give it a public IPv4 address and also run a web server from it. At least that is the conclusion I reached this morning.

MEAN Stack - Angular can only Communicate through the domain name

I have setup a Mean stack on a Digital Ocean Droplet based on UBUNTU 18.
I am using Angular6 on nginx port 80, nodejs on port 3333 which I run on the same machine. I have also enabled CORS on nodejs. The angular application gets build as prod and copied to the server. I have enabled as described on digital ocean the private ip and i can successfully curl the api (nodejs) using localhost, the internal IP and 127.0.0.1
Now the problem: When I am calling the API from the angular6 anything but the domain name is giving me an Error -> Connection Refused, Unknown Error! Locally on my development PC everything is working as It should! I thought it might be a cors issue but I am able to access via IP the remote API from my development machine without any issues. What am I missing? I find it very odd to be able to access it through the domain name and not via the internal IP...
Note that on the development PC angular is running as ng serve... the only difference is that the application is build as prod before uploading it to the remote server.
Angular cant access the private ip because the angular code runs off your browser and not the server. So unless your running the browser right on the server via vnc or something, your local machine cant access the private network (and thus the private ip).
Digital ocean probably recommend you set up a private ip so that you can put your database in the private network so its firewalled off.
Anyhoo, use the FQDN or the public ip in your angular code.

Is there a way to host a node.js server without a public IP?

I've made a simple Node.js app that i can host locally and using services like evennode. Now I want to do this on my home PC and it seems like a simple task to do - just port forward and get a domain name.
However, my problem is that i don't have a public IP. My ISP uses private/dynamic IP addresses which makes hosting impossible(?).
Is there a program or service that can fix my problem? I've found some for Apache/SQL servers but nothing for Node.js

How do I get acces to server running on Bluemix Paas?

Few days ago I wanted to launch my own Agario server. I assumed not to spend any money on hosting/vps etc. After a long search I found Bluemix PaaS, I put open source Agario clone Ogar (https://github.com/OgarProject/Ogar) in them and server has already started in 1523 port, but when i try to connect to this server via agario site ( connect("ws://appname.eu-gb.mybluemix.net:1523") ) I can't connect. I tried also other ways e.g. prepared agar.io link (agar.io?ip=appname.eu-gb.mybluemix.net), but nothing worked.
Has anyone met similar problem?
Inbound traffic is only on standard HTTP/HTTPS ports 80/443. Bluemix will tell your application what port to listen on with the VCAP_APP_PORT env variable. Inbound requests are then mapped to that port. So, once you bind to the VCAP_APP_PORT port, you should be able to connect to : ws://appname.eu-gb.mybluemix.net

Resources