Setup domain name with port no

By default, when a browser makes an HTTP request, the port used is 80. So, if you’re requesting example.com, it means you’re actually requesting example.com:80.

However, sometimes a project may be hosted on a different port, such as 3000 in the case of client-side JavaScript technology. In this case, you can access your website by using the URL example.com:3000.

In this article, we’ll learn how to open port 3000 without having to specify the domain name, similar to what we’re doing for port 80.

 

<VirtualHost *:80>
  ServerName example.com
  ServerAlias www.example.com

  ProxyRequests Off
  ProxyPreserveHost On
  ProxyVia Full

  ProxyPass / http://127.0.0.1:3000/
  ProxyPassReverse / http://127.0.0.1:3000/
</VirtualHost>

Change example.com with your domain name

Note: you must enable proxy

sudo a2enmod proxy proxy_http proxy_balancer lbmethod_byrequests

restart apache2 server

sudo systemctl restart apache2

Read more...