On linux, ports below 1024 can only be opened as root, so port 80 is limited by default.
if you want to publish your application on port 80, you need to redirect the request from port 80 to the port where you are going to run springapp port (for example, 8080)
Solution 1: HTTP Proxy
You can use the Apache2 server, which by default is allowed to work through port 80 and can redirect requests for you to Tomcat.
Configuration Example for Debian
sudo apt-get install apache2 a2enmod proxy a2enmod proxy_http cd /etc/apache2/sites-enabled sudo nano 000-default.conf
Edit file:
<VIRTUALHOST *:80> ProxyPreserveHost On # ... ProxyPass / http://localhost:8080/ </VIRTUALHOST>
Save file: Ctrl + O , ENTER , Ctrl + X
Note. To learn more about virtual host configurations, you can read the detailed Apache tutorial on this topic by clicking here .
Restart Apache2 to apply the changes:
sudo service apache2 restart
or
sudo systemctl restart apache2
Solution 2: Port Forwarding
Use iptables for redirects
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
if you need to use localhost also add this
iptables -t nat -I OUTPUT -p tcp -d 127.0.0.1 --dport 80 -j REDIRECT --to-ports 8080
Oskar dajnowicz
source share