When we create APIs using nodejs we often enable them to run on particular port number. It is all fine until we move into production environment where we don’t want our port number to visible to our clients while we are making the server request calls using the APIs.
So a solution would be to mask our port number and let apache handle the request and redirect the request to that server internally without revealing the port number. For this we need to edit the apache configuration like following.
Before editing run the below command
sudo a2enmod proxy_http
Open the file /etc/apache2/sites-enabled/000-default.conf using any editor and add the following lines under or above the directory tag. Note that if you are using SSL for your site i.e https enabled then you have to edit the file /etc/apache2/sites-enabled/000-default-le-ssl.conf to make it work properly for https enabled sites.
Allow from all
Then save the file and restart apache and try to run the API request without the port number.