Suppose we have a web app running on a port. For example nodejs runs server on a port. For accepting incoming connections on this port without actually exposing the port number is what we look for.
To solve this we can add few lines in our apache configuration to tell our web server to accept connections on a port.
Lets assume we are trying to access this url
http://127.0.0.1:8080/mybankapp
Open the file /etc/apache2/sites-available/000-default.conf using any editor and paste the below lines. You may take a backup of the above file before doing so.
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /mybankapp http://127.0.0.1:8080/mybankapp
ProxyPassReverse /mybankapp http://127.0.0.1:8080/mybankapp
</VirtualHost>
Before we restart apache we may enable some modules.
sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_balancer
sudo a2enmod lbmethod_byrequests
After we execute above command now we may restart apache.
sudo systemctl restart apache2
Now we can access our web app without the port number.