After using the one-click Mean.js deployment and adding a domain name, how does one remove the :3000 port number from the address?
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!
When starting the server set the port NODE_ENV=production PORT=80 node server
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:
sudo apt-get update
sudo apt-get install nginx
Then, replace the default server block in /etc/nginx/sites-available/default with the following:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Finally, restart nginx:
sudo service nginx restart
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
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.