Nodejs app loads in browser via ip + port but not domain + port. DNS set to DO servers in registrar account. A and CNAME are set. Help!

August 12, 2018 1.4k views
Node.js DNS Ubuntu

Using correct port (‘3000’) and A and CNAME set to domain and 'www’ alias, respectively. IP + port loads with no problem.

1 Answer

You need to setup apache web server as a reverse proxy for your nodejs web app so you can access it using the domain name, this is an example apache site for you to try it

<VirtualHost *:80>
  ProxyPass "/" "http://localhost:3000"
  ErrorLog ${APACHE_LOG_DIR}/nodejs_error.log
  CustomLog ${APACHE_LOG_DIR}/nodejs_access.log combined

Create a file called in /etc/apache2/sites-available/ with the above content, make sure to enable the proxy module and the new site with these commands

sudo a2enmod proxy
sudo a2ensite
sudo systemctl restart apache2

Now you can access your app using as domain name.

Hope this helps

Have another answer? Share your knowledge.