Reputation: 171
I'm creating node.js project now. I've a VPS which ubuntu 16.04 as op system and nginx as http server installed on it. As you know we use URL with port number like http://localhost.com:3000 to access our node.js projects. I wonder is there any way to access without port number like http://localhost.com like normal php and other projects?
Upvotes: 0
Views: 2422
Reputation: 900
Use Apache or Nginx as a reverse proxy.
Forward port 80 to port 3000 with iptables
sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 3000
References:
Upvotes: 1
Reputation: 47956
The only reason we use those kinds of port numbers for local development is because ports under 1024 are "reserved" and require root permissions to be used. You can still use port 80 for local development if you set your node server to listen on this port.
If you do make these changes to your node server, in order to run it locally you will need to run it as root or using sudo
.
Upvotes: 0