After using the one-click Mean.js deployment and adding a domain name, how does one remove the :3000 port number from the address?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
In order to bind a program to port 80 or any port under 1024, it needs to have root privileges. Running an app as root is usually a bad idea so what is usually done is running a reverse proxy such as nginx or HAProxy on port 80 that forwards all incoming requests to the MEAN app on port 3000.
First, install nginx:
Then, replace the default server block in
/etc/nginx/sites-available/default
with the following:Finally, restart nginx:
Nginx should now be listening on port 80 and forwarding all requests to the MEAN app that is running on port 3000.
If you’re running the app in production, you will need to set it up so that it automatically starts on boot and restarts when it crashes. Take a look at the Install PM2 and Manage Application with PM2 sections in the following tutorial:
How To Set Up a Node.js Application for Production on Ubuntu 14.04
When starting the server set the port
NODE_ENV=production PORT=80 node server