Node Js

I have purchased http://pipad.org

Let's say I make a simple node.js "serve a web page saying hello world" webServer,

var http = require("http");

http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);

type thing

and put it on my old MacBook, in a corner of the room with a permanent Internet connection.

Now I want someone else to be able to go to http://pipad.org see my hello world page.

- - -

I think I need some kind of {dynamic DNS / DNS redirect} service:
https://www.dnsdynamic.org/api.php
?

And I need to create an account with them, and point http://pipad.org to http://myfoo.dnsdynamic.org

And from my Node.js script I need to get the public IP of the machine:
http://stackoverflow.com/questions/10750303/how-can-i-get-the-local-ip-address-in-node-js
http://stackoverflow.com/questions/3653065/get-local-ip-address-in-node-js

var os = require('os')

var interfaces = os.networkInterfaces();
var addresses = [];
for (k in interfaces) {
for (k2 in interfaces[k]) {
var address = interfaces[k][k2];
if (address.family == 'IPv4' && !address.internal) {
addresses.push(address.address)
}
}
}

console.log(addresses)
And inform the DNS redirect Service:
https://username:password@www.dnsdynamic.org/api/?hostname=techno.ns360.info&myip=127.0.0.1

Links I'm not sure about:
https://ddserver.0x80.io/
http://sourceforge.net/p/ddclient/code/HEAD/tree/trunk/ddclient

http://www.matt-knight.co.uk/2011/dynamic-dns-ip-updating-with-node-js/


EDIT: ok now I am using Digital Ocean
I have a VPS with them —virtual private server, which is running Ubuntu

SSH in…

ssh root@188.226.178.182

Install node.js…

sudo apt-get install g++ curl libssl-dev apache2-utils
sudo apt-get install git-core
git clone git://github.com/joyent/node.git
cd node
git checkout v0.10.26
./configure 
apt-get install make
make
 sudo make install

Remote-mount filesystem from my OSX:
https://www.digitalocean.com/community/articles/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh
I used homebrew to install osxfuse (which prompted me to run a couple of extra commands which I did) then sshfs

brew install osxfuse
sudo /bin/cp -RfX /usr/local/Cellar/osxfuse/2.6.2/Library/Filesystems/osxfusefs.fs /Library/Filesystems
sudo chmod +s /Library/Filesystems/osxfusefs.fs/Support/load_osxfusefs
brew install sshfs

Then I:

mkdir ~/Droplet
sshfs root@188.226.178.182:/ ~/Droplet

(can't use /mnt/bla/ because it isn't in my local space, so the documentation page is wrong there), and bingo, I have access to the remote filesystem.

ls ~/Droplet/
cd ~/Droplet/home
atom server.js

Notice I can use my local text editor to create the file.

I then follow http://www.nodebeginner.org/#hello-world but use port 80, so:

server.js:

var http = require("http");

http.createServer(function(request, response) {
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write("Hello World");
  response.end();
}).listen(80);

Now from my FTP session on the server, I do:

sudo node server.js

Now I point my browser to http://188.226.178.182/, and:

Hello World

Next step:
http://proghowto.com/iptables-redirect-port-80-to-port-8080

https://paste.gparent.org/

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License