Allowing external access to node.js application while hosting through XAMPP - node.js

So I have the following URL that leads external users to my port-forwarded XAMPP website.
http://ip_to_my_computer:433
However, my node server is on port 466. How do I connect to it? I can't do
var client = io.connect('http://ip_to_my_computer:433:466');
Thanks!

It looks to me like you're trying to initiate a client request from your XAMPP hosted server (like a .php or .js script) to your Node.js instance?
Simply:
var client = io.connect('http://ip_to_my_computer:node_server_port');
And in your case, you claim your Node server is running on port 466.
I'd bet though that your OS will block a port that low - try changing your Node server to listen on a port between 8000 - 9000.

Related

Best practice for Deploy Node Express application and php application on AWS ec2 instance

I have an AWS ec2 instance along with one domain. I want to deploy my express node application and PHP application on the same server without adding a port with the domain.
For PHP deployment I have configured xampp server with a default port of 80.
And my node application runs on port 3000.
Currently, I am accessing the node app using - mydomain.com:3000
and for the PHP - mydomain.com/website
I wanted to use an express node app without entering the port number. example - mydomain.com
Is there any way to configure it with my given scenario?
Perhaps what you want is to run two different applications on one physical server.
How about approaching the concept of load balancing on one server?
Typically, you can implement this using nginx's reverse proxy and upstream.
For example, if the node server is running on port 3000 and the php server is running on port 4000
In nginx node.mydomain.com is port 3000
php.mydomain.com can send on port 4000.

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.

Local server http communication and angular browser rendering

I think I'm doing something completely the wrong way.
I have an Nodejs server running that read in a DB and serve with express some data via http locally (it has to only be accessed locally). It sends the data on localhost on some port (8080 for example). Then I have an angular app on the server that get these datas from an http request on localhost:8080 and display them. The angular app runs locally on localhost:4200.
I was building the entire stuff on my computer and that was working perfectly (I have no problem with CORS). Then I deployed it on a server, and I accessed it via ssh port forwarding. Basically I forward localhost:4200 on the server via ssh on my local computer on localhost:8090.
And my problem is that, when loading and executing the angular app in my browser via port redirection, it's doing a get request to localhost:8080. So it's trying to communicate with the localhost it's running on, which is the client itself.
If you understood my spaghetti situation, there is actually a dirty solution : redirect localhost:8080 on the server to localhost:8080 on the client.
Is there any way to do the get request server side and not in the client's browser so that localhost correspond to the server? Is there a better way to do what I'm trying to do?
I can sum up by : How can you access another local service on localhost on the server with angular app since it executes in the client browser and localhost will refer to client localhost.
Try to use any web server (such as nginx or apache2 or etc.) in your server and make use of proxy and reverse proxy with your node application, it will work
angular2-router-and-express-integration

make a localhost port accessible over internet - NodeJS

I'm asking this question specific to nodeJS , but maybe it applies to other web development frameworks as well.
I have a nodeJS Express hello world application running on my laptop listening to port 3000(I'm using Linux Mint Sylvia 18.3).The localhost:3000 and < localIP >:3000 requests to access this app works fine from the same machine and also within the local network of my Router. But when I do a port forwarding on my router to port 3000, and try to access this app via < publicIP >: 3000, it doesn't work.
This is not for any production purposes, but just for learning. How do i make my hello world app accessible over the internet without the help of any 3rd party web server applications (apache/nginx etc) or any local tunnelling (like ngrok)- i.e just like how we access a HelloWorld app from AWS EC2 server by accessing the server < instance >:< port >.
You can make your Node JS or any other application on any port public temporarily by using
Localtunnel
ngrok

Socket.io on port 80

I've made a node application which listens on port 80, my application works fine on localhost, but when I run it on my VPS, I get a different log and a different result ( websockets just don't work )
A comparison between localhost's log and VPS' log:
Node's log on localhost
Node's log on VPS
As you see, in VPS, xhr is used instead of websocket after it says "info: transport end (socket end)"
I don't use any web server on my VPS and I ran my application as root.
Are you running a web server in front of your node app on your VPS? If so, make sure it is new enough and properly configured to do websockets. For instance, on modern Ubuntu the stock nginx is not new enough yet to support web sockets, so you have to install a separate package to get websocket support.
2nd guess: is there a proxy server between your browser and your VPS?
Have you run it as the super user on the VPS? Normal users are typically blocked from opening ports below 1024.
Our server hosted on VPS, using port 80. The io connection fired through cellular data and through WIFI fine, but in some wifi networks it didn't.
So we had used different port, then it works.

Resources