Is it possible to host a web server from behind a NAT

It is feasible to host a server behind NAT as you describe.
Look at this Ubuntu help page on ServersBehindNAT for basics.

Some more references,

  1. Hosting Apache server behind a NAT
  2. Setting up a server behind a NAT
    this uses a NAT Buffalo AirStation series router and Linksys router examples
  3. Windows XP Internet Connection Sharing method. if you have a Windows machine doing NAT
  4. [If you are using XP, you may also use IIS 6 5 (1 virtual host support) by going to Control Panel > Add and Remove Programs > Add Windows Component > Internet Information Services.

This is assuming you know how to host a web server and need ideas on NAT.


You can set up an I2P tunnel.

If you only need TCP, you can set up a Tor hidden service.

If you only need to host static web pages, you can set up a ZeroNet site.

They all require no port forwarding.


After checking all these answers and linked how-to's I figured they all involve elaborate setups with big programs (that are partially made for other purposes) and config files and stuff so I decided to write my own solution.

https://github.com/rofl0r/nat-tunnel

It's a 250 line python script, which you can run directly from the git checkout.

Example: You have a HTTP server listening on your local machine on port 80. You want to make it available on your cloud server/VPS/etc's public IP on port 7000. We use port 8000 on the cloud server for the control channel.

use like

Server:

natsrv.py --mode server --secret s3cretP4ss --public 0.0.0.0:7000 --admin 0.0.0.0:8000

Client:

natsrv.py --mode client --secret s3cretP4ss --local localhost:80 --admin example.com:8000