Let's say you want to forward requests going to 80 to a server listening on port 8080.
Note that you will need to make sure port 8080 is allowed, otherwise ufw will block the requests that are redirected to 8080.
sudo ufw allow 8080/tcp
There are no ufw commands for setting up the port forwards, so it must be done via configuraton files. Add the lines below to /etc/ufw/before.rules, before the filter section, right at the top of the file:
*nat
:PREROUTING ACCEPT [0:0]
-A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
COMMIT
Then restart and enable ufw to start on boot:
sudo ufw enable
ufw forward 80 to 8080? I thought UFW was Uncomplicated. – Tom Mar 11 '12 at 11:58/var/log/syslogafter turning loggin on:[52627.259812] [UFW BLOCK] IN=eth0 OUT= MAC=xxx SRC=xxx DST=xxx LEN=60 TOS=0x00 PREC=0x00 TTL=59 ID=59278 DF PROTO=TCP SPT=53997 DPT=8080 WINDOW=14600 RES=0x00 SYN URGP=0. It may be useful to know that before everything, I denied all incoming requests usingufw deny incomingand allowed onlyssh,80,443. Could someone please advise what is the problem? – Yuriy Nakonechnyy Jul 31 '14 at 08:05sudo ufw allow 8080/tcpfixed the problem for me. – Tim Swast Jan 29 '16 at 03:19