I have a process that listens for incoming port 80 and 443 traffic and then sends it out to an extranet recipient. It's a proxy but I don't want to use that term because I need to send ITS outgoing requests through a company proxy. However, the app is not designed with a config option for proxy and it does not respect any system proxy settings.

I was experimenting with firewalld but could not change the destination IP of only the port 80 and 443 OUTGOING traffic. I think it ended up redirecting all INCOMING traffic coming on 80 and 443.

I can post some rules I have used but I'm hoping this is straightforward to firewalld veterans - I have only touched it a couple of times.

This is on RHEL 7, btw.


I would like to suggest to you to use NAT for this matter :

1 - Enable IP forwarding : echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf ; sudo sysctl -w net.ipv4.ip_forward=1

2 - Start IPtables : sudo systemctl start iptables

3- Forward Incoming traffic on port 443 & 80 to your dest_ip:dest_port

sudo iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to-destination <dest_ip>:<dest_port>
sudo iptables -t nat -A PREROUTING -p tcp --dport 443 -j DNAT --to-destination <dest_ip>:<dest_port>
sudo iptables -t nat -A POSTROUTING -p tcp -d <dest_ip> --dport <dest_port> -j SNAT --to-source <source_ip>

4 - Check that the trules are correctly set : sudo iptables -t nat -L -n

5 - Test & then make your rules permanent :

sudo iptables-save | sudo tee /etc/sysconfig/iptables

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.