A machine (M) is behind a NAT.
Port X is forwarded through, and available to the internet.
My application wants to connect to port Y.
How to I configure M to forward incoming data on port X to port Y?
I think that you are talking about redirecting from the same machine, if so, you could try with iptables,