nodejs hosting from my laptop - node.js

I have a website that uses nodejs with express. The website is working fine on my localhost.
I am not able to find a way to host the website from my laptop i.e. allowing external users to connect to it remotely.
I wanted to check if this is possible. I am using windows 7.
I used to do the same job with php however, I used wamp server. Is there a similar way for nodejs?
Thank you

I used to do the same job with php however, I used wamp server. Is there a similar way for nodejs?
It's identical. Assuming Node.js is listening on the correct interfaces, there is no reason why you can't forward a port in from your router to your server on your laptop.

I use ngrok. You go to ngrok.com and download the client. Then you can do a quick and easy command from your shell and tell ngrok to open the port you are running your Node site on. Something like...
ngrok http 3000

Related

Deploy a node js application on fedora workstation 36

I have a nodejs application that i wanted to deploy on a local server(which is running Fedora 36). I have developed the NodeJS side on another pc,and it works fine when the node is running. But when i copy the node server directory to the fedora serve and run it,it only works on local host. I couldnot access the server even if i'm in the same network.
I'm developing the app for a small locally connected PC and i donot want to use the hosting companies as well as Heroku. Is the it the firewall that is blocking my request to the server? What option do i have to host it locally? Is there a better way?
Your node.js server is running on a port determined at the end of the script usually. Sometimes 3000. but can be anything. The correct way for others to access is as you say...
http://your.network.ip.address:port/
or
example ip
http://192.168.0.3:3000
check your local ip and port where you run this server.
How could others, on a local network, access my NodeJS app while it's running on my machine?

Deploy ReactPHP on PHP host

I use the example for the chat server in ReactPHP. My server listens on port 8080
$socket = new React\Socket\Server(8080, $loop);
$server->listen($socket);
in my local PC. The written code is working correctly but when upload files into my Linux host, nothing works. I wrote a ticket to the support team from my hoster, they said that this is not possible in Linux. Is that correct?
ReactPHP core team member here. Your run-of-the-mill shared hosting won't be able to host this. You need your own server, VPS, or bare metal, to run ReactPHP as a server because you're dealing with a daemon process. And shared hosting generally doesn't support that.
My suggestion is to get a VPS somewhere and look into Supervisor to keep your process running and restart it when something happens to it. This also requires you to manage your own server with all the firewalling and networking knowledge that comes with it.

Setup Node-JS to run as a website without a port on a windows machine with apache

This has been a very difficult thing to investigate as well as configure, everyone oneline just have half documentation, for some reasons everyone is concentrated on the running of nodejs on the commandline, or if not, they want to run it on http://localhost:8080.
What I need is a full documentation from installation, configuration, vhost setup, to running a nodejs website such as http://node.local/ website on my work machine.
Please assist, I have been googling for 3 days on this, have not found anything, I need to setup http://node.local website fully running nodejs.
Use proxy http server. For example nginx is pretty easy to configure.
And it will proxy requests from port 80 to port 3000, for example.
Here you can find quick guide to setup one.

Node.js for a website

Can I use node.js to build a web server and domain from scratch, instead of using apache for a website? Can All the backend hosting and domain work be done by node.js?
Thank in advanced, I'm trying to build a site for my resumé, would like to build it from scratch, to showcase my resumé. Back to front end. ...etc
So, sort of yes, but also sort of no. To build a back end with node you need to use a framework like express, and to serve it you'd need something like this. But to safely expose it to the open internet, you should definitely use apache or nginx to proxy requests to the port that your app is listening on. This is because it's extremely unsafe to expose your node server to the internet, and because both ports 80 and 443 require root privilege, making it even more unsafe. But if you really want to serve directly to your js backend, you can do so with something like this Best practices when running Node.js with port 80 (Ubuntu / Linode) for linux or this https://unix.stackexchange.com/questions/319734/pf-forwarding-all-packets-on-port-80-from-any-interface-to-socks-proxy for mac. This also requires root privilege to implement, and is still extremely unsafe.

How to use Redis / Node.Js on a production server

I get what Redis and Node.js are but i don't understand how to run them on a live server. Locally its an install and you use the command line to get them running but i don't know how to install them on a live server.
I've already browsed around a bit but im still confused and also isn't Node.JS a server itself so its like running a server on a server? wouldn't that have effects on performance and what not?
I'm just confused on how it would work, any explanation will be great.. thanks
Redis & Node.js = Software
You install those on a physical machine, a computer. A node.js server is not a physical server, but an application that can handle HTTP requests. Normally, a node.js server runs on a port on a physical machine. So any HTTP requests sent to that port are handled by the node.js application. You can use a webserver, which is another piece of software that handles HTTP requests, like Nginx or Apache to manage multiple domains on a physical machine (the server). Redis also runs on a physical machine and listens on a specified port.
For example, I have a VPS with 4 websites on it managed by Nginx. Two of those websites are Laravel projects that connect to a MySQL server (on another machine) and to a Redis server on the same machine. The other two are node.js applications which don't need a database or Redis, so they just listen on their own ports and Nginx proxies all connections to their domainnames to those ports.
So you're not actually running a server on a server, but you're running software that handles certain things on a server.
There are different ways to run a node service. I strongly recommend docker to run everything but here is a short list of the most popular ones:
https://www.docker.com/ https://hub.docker.com/_/node/
http://pm2.keymetrics.io/
https://www.npmjs.com/package/forever (seems like a bit outdated)

Resources