简体   繁体   中英

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.

You need to have a NIC associated with your VM. The NIC has a public IP address associated with it, and the NIC is in a network security group (NSG) that defines all the rules. Once you have attached the NSG to the NIC, you can go into the NSGs settings and modify the inbound and outbound security rules.

This answer shows a bit better what you are after..

Also here is a picture of what you are trying to do. It is possible...

在此处输入图片说明

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM