MEAN Stack - Angular can only Communicate through the domain name - node.js

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.

Related

How to deploy NodeJS Server app using AWS EC2 public IP?

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

Deploy Create-React-App on a remote Windows Server

I am an inexperienced intern working with a remote Windows Server and React. The Windows Server is running in the company network. I have created a dynamic React website with a NodeJs backend and React Router. I have only ran it on the localhost development server. I want to try to deploy it on the remote Windows Server and give it a custom domain name (Something which can be accessed like servername/myreactapp/).
So far, I have had no success trying to make it work with IIS, even with a web.config file (I get 404 and 500 errors). I am currently making it work by actually running the development server and the nodejs server in the Windows Server, and I access it through the server IP at port 3000.
An improvement would be to be able to access the port through the server name (like servername:3000, instead of the server_ip:3000), but ideally I want to be able to access it like servername/myreactapp/.
Any help would be appreciated. Thank you very much.
The simple solution would be to run your app on port 80 then you will not have to specify the port number.
The best solution would be to set up Nginx on the server and proxy_pass / route to port 3000.
If its running on localhost, which would be port 80, the url would be like http://your_server_name:80, and would be accessible by anyone on the same network, as long as your authentication allows it.

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 to access remote machine nodeserver url from my system if both the systems are behind proxy

Suppose if my ip address is : 192.65.35.12. In this machine I'm running node server. I can access the webpages by using this url: http://localhost:3000/ in the same machine.
But, if I'm trying to access the node server from a remote machine having the ip 192.65.35.11. It does not work. I used the below url to access the url from the remote machine: http://192.65.35.12:3000/
I'm facing network connectivity issues.
Do, I need to change any settings in node.js for remote access.
Then, how can I access the node server from the remote machine.
if you can access localhost:3000, then type in 192.65.35.12:3000 on same machine. and if you are having problems connecting, then no outside computer going to connect. and you need to adjust your nodejs settings.
if you have server at home, and trying to connect from some place else not at home. you are more likely looking for something like "dynamic ip address" example: http://www.noip.com/ it helps getting past ISP (internet server providers) and your own routers, and publishing your ip address.
if you are dealing with 2 computers in your same house or business and passing through your own router, try changing the 192.65.35.12 to DMZ. basically by passing all router safety, if that happens, you are not opening correct ports on the router. or not setting other setting correctly.

Port forward not working to set a local web server

I have just created a simple web server using node server and it's running fine. I can access it from the same PC by going to address http://127.0.0.1:1337.
Now I want to access that web server from my WAN IP. I got my my using whatismyip and got something like 110.36.xxx.xxx.
When I tried http://110.36.xxx.xxx:1337, I got:
Firefox can't establish a connection to the server at 110.36.xxx.xxx:1337.
Here is the screenshot how I created the port forwarding in my router:
What's wrong here?
Localhost is only accessible from the same pc. You have to launch your webserver either on address 0.0.0.0 (it will be available on all network interfaces) or 192.186.0.5 so that it is accessible from your wan interface

Resources