Forward only web traffic to another interface

Solution 1:

ufw will not solve your problem that will allow forwarding but it will not do forwarding . if you want to forward your traffic then you have to write NAT rule that will forward your traffic that comes on public ip to private ip.

If you want to allow forwarding from particular network to another network then you can use like:

sudo ufw route allow in on eth0 out  on  eth1  to  10.0.0.0/8 port 80  from 192.168.0.0/16

or

If you want to forward all network request then you can use like

sudo ufw route allow in on eth0 out  on  eth1  to  any port 80  from any

It will show like :

sudo ufw status
Status: active
To                         Action      From
--                         ------      ----
10.0.0.0/8 80 on eth1      ALLOW FWD   192.168.0.0/16 on eth0

For more info you can see

man ufw