How can I host a node.js website on the my local network? - node.js

I have created a web app with node.js but i want to test it on my phone and other devices.
Something like prepros works for static sites as you put in your ip address on any device on the same wifi network and it will display the page.
How wold i set up my node app so it works on the network not just on localhost?

You need to use the ip 0.0.0.0 instead of 127.0.0.1, it will make the server listens all interface.
You may need to use sudo to listen that IP.

Related

How can I make my node.js app accessible public?

Today I made my raspberry pi zero w server. Installed node, pm2, git, nginx. etc, everything worked fine until I tried to make app accessible publically by nginx.
Whenever I try to use my domain or public IP I get into my operator login page:
picture of login page
It's my first app in node, so I don't even know if my nginx is well-configured.
nginx config where:
server_name is my public ipv4,
proxy_pass is raspberrypi local ip with port that node.js app is listening on.
And also you might find it useful: result of sudo netstat -an | grep LISTEN |grep :80
What I tried:
Setup custom domain with DNS record, it sends me back to login page
restart nginx configs plenty of times
The IP address you are using is the Internet-facing IP address of your router / modem. It is not the IP address of the computer running nginx (which probably doesn't have an Internet-facing IP address).
You might be able to configure your router to forward requests for a given port to the internal IP address of the computer running nginx on your LAN.
You might be better off using third-party hosting rather than exposing computers inside your network to the Internet.

Node.js & express how to open my rest api on localhost to remote partners?

My partners can send http requests to my domain, like this:
https://www.example.com/getrequest/
As my domain is public.
And I have also enabled CORS.
How to enable such a thing with my localhost during development?
I have tried to visit my Node.js server with my IP address in the url bar in the browser of a different device like this:
http://myip:8080
But it asks for the WiFi password.
How make my IP available for incoming requests, just similar to my VPS so it will be available to development with partners?
Thanks.
In order for your computer to be accessible from the internet you have to enable port forwarding for your router
Port Forwarding
The thing is that your router has a unique IP address yet many devices connect to it so they all share the same IP. The router with port forwarding links a specific device to a specific port so that you can access your computer from http://ROUTERIPADDRESS:DEVICEPORT from the outside world.

How to share web application on linux?

I host a web application on my laptop and I access it using 'localhost:9080/abc.com' and lets assume my IP is '192.168.10.20'
Now, I want my colleague to access this web application from his system 'web browser' by typing in '192.168.10.20:9080/abc.com'
As laptop is owned by 'company' I cannot install (or) use any third party softwares
How can I manage this on RHEL 6?
Assuming you're on the same network (LAN) then a client who connects to 192.168.10.20:9080 should have no problems (assuming the web aplication also listens to requests other than localhost).
If abc.com is just an "alias" you set up in your hosts file then no other person than yourself will be able to use abc.com to connect to 192.168.1.10.20, unless they have the same alias in their hosts file.
If you purchased a domain abc.com and set up it up to redirect to 192.168.10.20 it should work. But usually there are delays associated with updating a DNS so the time it takes for abc.com to be updated can take even a day.
Now if you have your colleagues on a different network (for example they want to connect from their homes when the laptop is connected to the internet at your place) it won't work with a bit of fiddling. Basically, when they try to connect the router gets a request from the client to connect to port 9080, but the router doesn't know what to do with it so nothing happens. You have to set up port forwarding in your routers settings so that all incoming traffic on port 9080 gets sent to 192.168.10.20.
And when they try to connect that way, they can not use the 192.168.10.20 ip adress, because it always refers to a adress on the local network. They have to use your external ip adress (google what is my ip adress).

How to access virtual box web server url access from outside network

I have the below the setup.
1)Desktop with windows 8 64bit os & Iam using net gear router connected to my desktop via Ethernet cable.
2)Currently iam using public ip or static ip(ex:123.45.67.890)from my isp.
3)Installed virtual box
4)Installed oracle linux 6.5 in virtual box
5)Installed oracle ebs.in virtual box
6)Virtual box network mode:bridge
7)My netgear router ip range 10.0.0.1 to 10.0.0.20
8)Assigned static ip in oracle ebs(10.0.0.30) with port 8000.
(note:the given ip is not in my router ip range)
9)Added host details(10.0.0.30 ebs.example.com) in my windows system32-->drivers-->etc folder-->host file.
Iam able to access url(http://ebs.example.com:8000) and I can ping ip of oracle ebs(10.0.0.30) from windows 8.and everything is fine.
My requirement is
10)I want to access the same url http://ebs.example.com:8000 from outside of my network.(eg:outside of my city or town).
(Note:I already tried by portforwarding 10.0.0.30 with port 8000 in my router but there is no luck)
Please can anybody help me on this request.
Virtualbox network interface in bridge mode is transparent to the router. It creates the virtual adapter in software mode and uses injection on your VB host network adapter to have the job done. It means that the router will see your VM as it does for any other computer, like if your VM were directly connected to the router. At this point you should assign a IP on the VM that's on under router IP range to avoid routing/permission/port translation problems.
Sure you will need port forward on the router but for testing purposes try to set the VM IP as DMZ on the router. With this setting all requests from outside world on any port will be redirected to the DMZ machine. If it works you can go more restrictive and forward just the needed ports.
Many ISPS blocks common server ports, like 8080. You must make sure you're using a port not blocked by the ISP. For this try setting up a service on a not common port (like HTTP on port 49010 or whatever port not listed by common services), and test it. If it works change the service to the desired port (8080), if it stops working it probably means that ISP is blocking port 8080.
You will not be able to access your VM from internet using such address like http://ebs.example.com:8000 or any other FQN in a simple manner as it does need DNS translation. Its possible doing so but you will need to buy and register some FQN and then find some service that offer DNS over Dynamic IP. Not sure what you mean by public or static IP because a static IP can be also public. In case you have a static IP you will not need specific services for dynamic IP but just the usual structure: Buy a domain name, buy or use own registar DNS servers to have a working FQN pointing to your IP.
Another approach is using a non FQN redirection service commonly used for dynamic IPs but that will work on static IPs also like DYN DNS, No-ip or any other.
With a static IP you dont even need some FQN. You can just use your IP directly like 123.45.67.890:8080 when need connection from internet.

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