Configure a local HTTP proxy to a Java application with Apache on Ubuntu 26.04 LTS
Suppose the local development app is served on the domain application.local, with the following entry in /etc/hosts:
127.0.0.1 application.local
Usually a web-based Java application runs on port 8080, with a local URL like http://application.local:8080/.
To reach that app at http://application.local without the port, configure Apache as a reverse proxy. Create a virtual host file under /etc/apache2/sites-available/, for example application.conf, with the following content:
<VirtualHost *:80>
ServerName application.local
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
</VirtualHost>
ProxyPreserveHost On forwards the browser’s Host header (application.local) to the backend instead of 127.0.0.1:8080. That usually matches what Java apps expect for host-based routing, redirects, and generated URLs. If something breaks, try removing this line or set ProxyPreserveHost Off so the backend sees the origin it was configured for.
Enable the required proxy modules, then enable the site, check the configuration, and reload Apache:
sudo a2enmod proxy proxy_http
sudo a2ensite application.conf
sudo apache2ctl configtest
sudo systemctl reload apache2
If a full restart is required:
sudo systemctl restart apache2
The site should now respond at http://application.local/ without specifying port :8080.