• Compute
    Compute

    Configure a popular Linux OS or use popular developer Tools

  • Cloud hosting
    Cloud hosting

    Host a VPS in the Cloud in seconds

  • Collaborate, CMS, CRM`s
    Collaborate, CMS, CRM`s

    Collaborate with these popular CMS, CRM & collaboration tools

  • Database & E-Commerce
    Database & E-Commerce

    Create a database or an E-Commerce environment in seconds

[Basic] "Forward" a port with UFW in Ubuntu 18.04 Linux

 

In this guide, we're going to briefly cover how to do a basic "port forward" with UFW.


The example we're going to use is forwarding traffic from your server's port 80 to a custom defined port. In this instance, our web server is set to only listen to traffic on port 8080, and we want our users to be able to access it by simply using the domain name without a port in the address bar (such as www.domain.tld)


First, we allow the port in UFW. (We're going to toss in a rule for ssh as a good measure just in case it wasn't set beforehand. This way we don't lose access to the server when re-enabling UFW)


sudo ufw allow 8080/tcp
sudo ufw allow ssh


Now we are going to add the following text to /etc/ufw/before.rules, before the filter section.


sudo nano /etc/ufw/before.rules


*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
COMMIT


sudo ufw disable

sudo ufw enable

Congratulations! Now your traffic for port 80 should be forwarded over to port 8080.



Join our Private Discord Chat to chat with, as well as find community assistance from other Verified SkySilk Users: https://invite.gg/SkySilk  


CLICK TO DEPLOY AN UBUNTU LINUX VPS

   

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.