Forward only web traffic to another interface
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
Related videos on Youtube
Darryl Williams
Cloud Infrastructure and DevOps Expert with around decade experience in IT Infrastructure. Expert in Designing and building Infrastructure as code, automation of cloud infrastructure provisioning , system provisioning , apps/Micro services deployments , CI/CD pipelines , building highly available and reliable IT Infrastructure platforms.
Updated on September 18, 2022Comments
-
Darryl Williams over 1 year
My Ubuntu server has two interfaces.
1) Public - eth0 2) Internal - eth1
How can I forward web traffic (port 80) to nginx running on eth1 from Public interface eth0 ? I don't know exact ufw rules to complete this.
Thanks
-
Thomas Ward over 8 yearsWhy is nginx listening on eth1 only?
-
Darryl Williams over 8 yearsbecause nginx is running in docker bind to eth1.
-
-
Darryl Williams over 8 yearsI tried , it is not working.
-
pl_rock over 8 yearshave you written any rule for outgoing . ? this will forward incoming address . write rule for outgoing
-
Darryl Williams over 8 yearsNo, there is not rule for outgoing
-
Darryl Williams over 8 yearsPlease give me rule for outgoing address also
-
pl_rock over 8 years
sudo ufw route allow in on eth0 out on eth1 to 10.0.0.0/8 port 80 from 192.168.0.0/16
sudo ufw route allow in on eth1 out on eth0 from 10.0.0.0/8 to 192.168.0.0/16
apply both rule -
Darryl Williams over 8 yearsLet us continue this discussion in chat.