Expose localhost: The slowest way


This is a short post, listing steps to expose a locally hosted resource and access it via the world wide web.

localhost

Any locally hosted server should work for this demonstration. Could be a simple one-line python server

python3 -m http.server 8080

You can run the server in a virtual environment for added security. Refer to qemu setup post. Run your web service inside the VM and expose the port using hostfwd

qemu-system-x86_64 -hda ubuntu-desktop.img.qcow2 -m 4G  -net user,hostfwd=tcp::8080-:8080 -net nic -accel whpx

onion service

Setup onion hidden service on your machine. It is a simple process once you have tor browser installed and learn a bit about directory structure. Detailed instructions can be found here at torproject website.

  • First install the tor browser, which is basically a custom firefox.
  • Locate the torrc file (mostly in Browser\TorBrowser\Data\Tor directory of installed location) and add the following two lines in it.
HiddenServiceDir <read_wrie_accessible_location>\hidden_service
HiddenServicePort 80 127.0.0.1:8080
  • Restart the tor browser and go to hidden_service directory, you will find a file named hostname. Open it and you’ll get your onion address.
xxxxxxxxxxxxxxxxxxxx.onion
  • Type this address in your tor browser and you’ll see your service running.

Tor2Web

The .onion services can be accessed within tor network only but thanks to the project called Tor2Web you can access these services through the internet using publicly hosted proxies.

It will be slow, very very slow, but it’ll work.