Redirect port from 8080 to 80 in linux server(1)

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

查看配置是否成功
# iptables -t nat -L


Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination
REDIRECT   tcp  --  anywhere             anywhere            tcp dpt:http redir ports 8080

记住最后要save
iptables-save

移除重定向
# iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

你可能感兴趣的:(redirect)