Data not displaying from website hosted on AWS - node.js

I am facing very weird problem.Please help.
I have developed website using MEAN stack and it is hosted on aws ec2 instance.
If I access that website from my laptop, I can see the data(from mongodb installed on server) in my website.But at the same time when I access the website from some other laptop or say mobile phone(using browser), all the tables are coming blank without any data.
I am not getting, why It is working on my laptop as there is no relation between aws instance and my machine.Except that I use their console/dashboard from my machine.
Thanks.

Please check if you set your laptop host file while developing the website to resolve to the AWS EC2 instance IP where your website is hosted.
Or check the EC2 instance security group if you have opened the HTTP port of the instance just to your IP address.
As above 2 are the only causes that might give the issue mentioned by you.

Related

Nodes.js Rest API

I'm learning how to code Rest API with node.js, but I'm wondering what is the next step to send a REST API on a real server (once it's working with localhost)? It's not easy to find how to proceed on the web... Any suggestions?
You have 2 options.
Self Hosting
Host it on your own machine.
You can use a service like ngrok or PageKite. They are super simple to try and are free to experiment.
They will generate an URL for you, than you can access your server through that .
You can also do it the hard way.
On your router settings you need to forward the port you are using to your machine.
Also on your router settings, you need to make your internal IP static.
Create a firewall exception for that port.
With that done, you can reach your server through your public IP address.
Cloud Hosting
VPS (Cheaper, but not as scalable)
You can rent a Virtual Private Server, which is a virtual machine running the OS of your preference (Linux is more common). Then you can just upload your code and start your server. Some even offer free domains for you to reach the server.
There are many hosting platforms. Check this.
Cloud hosting Platforms (More expensive, infinitely scalable)
Platforms like AWS or DigitalOcean offer virtual machines that are infinitely scalable.
AWS offers the ec2 service and DigitalOcean offers the Droplets service.
There are LOTS of resources online on how to do it.
aws ec2
aws ec2
DigitalOcean
DigitalOcean
VPS
VPS
Paste this in Google how to deploy nodejs vps OR digitalocean OR aws OR ec2
And be happy

Mean stack app not working well on AWS EC2 instance

I have developed a SaaS app using MEAN that is working perfect on my local machines and server now I have deploy my app on AWS EC2 instance.
now I have problem with my server whenever I request with big data query my ec2 instance / server stop I cannot access it from putty or FileZilla.
Should I use other hosting service or there is my app infrastructure problem?
(sorry for bad English)
It seems like your EC2 instance is out of resources, hence not responding to the Putty/FileZilla apps.
You may check the CPU% on the monitoring tab in EC2 console, or via CloudWatch.
Also, You may install and configure CloudWatchAgent on your instance to get improved logging of RAM and also application logs.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/Install-CloudWatch-Agent.html
If the problems is resources (CPU, RAM, Disk), You can change your instance type to a more appropriate one.
BTW, instead of using Putty/FileZilla, you can connect with you instance via the connect tab or session manager (see attached image). Right click on the instance name, and choose "connect".

How to display web app running on an AWS Lightsail GitLab CE Linux instance in local browser

I have a Flask web app in my AWS Lightsail GitLab CE Linux instance that I want to display on my local browser (in order to check how the UI looks). I've tried entering the given public IP address with the port numbers specified in the firewall rules, but they all time out. Can anyone tell me how to do this?

Videojs Record not accessing camera/microphone or Share Screen if website running on AWS EC2 & Azure VM

The web page has the capability of using videojs record for screen recording and webcam video recording. It is working fine on localhost and on shared hosting. But I have deployed website on AWS EC2 and Azure VM for testing and videojs record is not working there. As per my understanding it is all javascript and should be working on browsers where ever the site is hosted.
Any clue?
SCREENSHOT-1:
When user clicks on a button within square box, a window should appear for confirmation (shown in SCREENSHOT-2)
SCREENSHOT-2
This window appears if site is running on localhost or shared hosting service, but not if site is running on Azure VM or AWS EC2.
Testing Pages
https://clearn.codeschunks.com/test/recordvideo (working)
http://ec2-54-185-50-254.us-west-2.compute.amazonaws.com/index.php/test/recordvideo (not working)
The problem is due to security (https). If you see your connection to codeschunk.com is secure (https) while hosting on EC2 your connection is not secure (http only). You can solve it by two methods.
By making your connection to your hosting on EC2 instance secure (https). It can be done by installing SSL Certificate.
Or
Follow these steps in your browser (These are for chrome)
Navigate to chrome://flags/#unsafely-treat-insecure-origin-as-secure in Chrome.
Find and enable the Insecure origins treated as secure section
Add your address you want to ignore the secure origin policy for. In your case the address is http://ec2-54-185-50-254.us-west-2.compute.amazonaws.com/index.php/test/recordvideo
Relaunch the browser.
Now it should work.

Google Cloud App Connecting to Atlas MongoDB

I am a newbee to Google Cloud, however, I setup the project based on Standard App Engine based for my Node.JS application. I downloaded the code from GIT and able to deploy. In my code, it tries to make a Mongo connection to my Replication Server that is hosted at Atlas MongoDB (I guess it's on AWS EC2 instance). I have access control enabled so only server to server with known IPs can connect to my MongoDB.
Obviously I was expecting the connection from my freshly deployed app to fail. So to remediate I want to add the external IP of the instance from Google Cloud (whatever is the Public IP that is seen) to Mongo Network Access. I tried a few IP address I thought are the right ones but it's not working. I see the connection is trying to make to Atlas but it's failing because I am not sure what Public IP address is seen from AppEngine (Docker Instance?)where my app is running.
I tried 0.0.0.0/0 - open to all clients and my app works just fine, however I definitely don't want to open MongoDB access to entire world. If anybody knows more about Google Cloud please help.
Thanks in advance for replying if you have important info to share.
Google App Engine doesn't have an External/Static IP that you can refer. This can be achieved by using a VM on Google Compute Engine that has an External IP with proxy to your App Engine.
Besides that, there is a Feature Request open for this to be checked by Google that you can access here:
Provide static IP for outbound urlfetch requests
Besides that, you can access the documentation Static IP Addresses and App Engine apps, to find out more information on options already available on App Engine.
Please, let me know if the information helped you.

Resources