How to make MEAN droplet run on port 80?

July 28, 2015 5.1k views
Node.js MEAN

The title says it all. I want to make this run on port 80.

I tried this command NODE_ENV=production PORT=80 grunt, but it only displays a blank screen.

Is there something else that needs to be setup? Express possibly?

2 Answers

You should not run MEAN directly over port 80, use Nginx as a proxy for it, is more secure and reliable.

  • Is this easy to setup? I’m not familiar with it. I don’t normally deal with server admin stuff. Just trying to get a project setup so I can start writing code.

  • Yes, it is easy, there is plenty tutorials for nginx and mean on the tutorials section of this community.

    Look for:
    -how to install nginx on (your os).
    -how to proxy MEAN on nginx.

    it should be easy if you read the tutorials

  • I added this configuration file and restarted nginx. When I go to my site it goes to a nginx splash screen.

    Is there something I’m missing?

    The file is located at
    /etc/nginx/sites-available/my domain

  • @billabrian6 you need to place the server block file in /etc/nginx/sites-enabled in order to activate it. The easiest way to do that would be creating a symbolic link to it:

    sudo ln -s /etc/nginx/sites-available/domain /etc/nginx/sites-enabled/domain

    Don’t forget to restart Nginx so that the changes take effect.

  • If you have nginx installed and its showing you the default nginx page then nginx is correctly installed, now you have to modify you nginx default site and add a proxy directive to your app:port or create a virtual site and do the same, in your case maybe is easier to just modify default site.

    So as I’m not aware of your OS/Disto you have toi look for the default.conf file inside nginx configuration files, something like this /etc/nginx/conf.d/default.conf or /etc/nginx/sites-enabled/default.conf

    copy paste the content here and I’ll help you with the changes.

  • I’m good to go. Thanks guys!

Have another answer? Share your knowledge.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!