Forward external traffic to 127.0.0.1
Posted
by
user2939415
on Server Fault
See other posts from Server Fault
or by user2939415
Published on 2014-05-30T04:26:50Z
Indexed on
2014/05/30
15:32 UTC
Read the original article
Hit count: 124
iptables
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/");
© Server Fault or respective owner