Is it possible to run a Node.js application that is accessible to the internet without a reverse proxy?
If so how does one set it up? IP and port wise.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You can actually do this with iptables pretty easily:
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
You’ll want to add that line (minus sudo) to your /etc/rc.local file as well to start the redirection on boot. This also assumes you’re running your app on port 3000 (configured in your code), but you can redirect it to wherever by changing the final value in that command.
Alternatively, if you’re using Express, the app.listen call accepts a hostname or IP address:
app.listen(80, <the IP address you want to listen on>, function() {<your callback here>});
I’ve heard a lot of people say not to run apps directly on port 80, and although I can’t think of a reason off the top of my head, instinctively it seems like a bad idea. Any particular reason you don’t want to use a reverse proxy?
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.