Reputation: 167
I have created a basic web server using node.js which listens to port 3000 on my desktop. It serves static HTML files (jQuery mobile documents actually).
I am able to access the site on the local host (my Windows 7 desktop) using http://127.0.0.1:3000/
.
I want to be able to access the site from my mobile over the internet.
Is there a way this can be done?
Upvotes: 1
Views: 2644
Reputation: 3096
Ok, old question but for future me, you can nowadays use ngrok
Secure tunnels to localhost
”I want to expose a local server behind a NAT or firewall to the internet.”
Of course not for production, but perfect to develop webhooks!
Upvotes: 1
Reputation: 8635
Flexible solution (not for production, but easy, and without need to configure routers) is using localhost tunnel services, since you are on node.js, there is already one available:
localtunnel. To use it:
Reasoning against using it in production:
Upvotes: 2
Reputation: 709
What you are trying to do is not a safe and secure option.
As you're using nodejs, have you considered deploying your app as PaaS plateform as heroku.com ?
The options listed are all functional, but not recommended: You need to use an external service to serve your files.
Upvotes: 0
Reputation: 7096
I like to use nginx, Here is an example.
upstream app_myapp {
server 127.0.0.1:8080;
}
server {
listen 0.0.0.0:80;
server_name www.myhost.com myhost.com;
location / {
auth_basic "Restricted";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://app_myapp/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Upvotes: 0
Reputation: 4669
Look into port forwarding on your router. Set the port forward for HTML requests to 3000. Then find out what your router's IP address is.
Then use http://[routerIP]:port/
to access your site.
And pray you don't get hacked like mad for opening up that port with no security.
Upvotes: 0