Forward external traffic to 127.0.0.1
- by user2939415
I have an HTTP server running on 127.0.0.1:8000. How can I use iptables or something to route external traffic to it? I want to be able to access my.ip.addr:8000 from my browser.
iptables -A PREROUTING -i eth0 -p tcp --dport 8000 -j REDIRECT --to-ports 8000
does not help
EDIT:
To test whether or not this works I am using the following node.js script:
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000, "127.0.0.1");
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");