Search code examples
azuremappingazure-virtual-machineports

VM on Azure how to map public port 80 to private port 8080


I installed VM on Azure and I am trying to map public port 80 to private port 8080. I can find a lot of answers how to do do it using the old interface (using Endpoints) but I cannot find anything how to do it with the new portal (inbound and outbound security rules, Endpoins are gone). I created the inbound rules and I can access the app on port 8080 when I expose it, but I cannot figure out how to implement the translation from port 80 into private 8080.


Solution

  • As it seems that with ARM it is no more possible to configure the port mapping, to avoid need of adding another server working as a load balancer, I created a rule in iptables (I am running Ubuntu server):

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

    Not ideal but it works.