AWS forward port 8000 from elb to port 8000 of EC2

泄露秘密 提交于 2019-12-10 23:09:19

问题


I have en ELB with multiple EC2 instances registered in target groups. I am using port a php application which is running properly. It has SSL.

I want to use port 8000 for my node application. What I would like to do is I want to forward my-elb-address:8000 to any-ec2-ip:8000. So when i access the domain attached to ELB witjh port 8000 it would forward that to ec2 with port 8000. How can I accomplish this? Is their any other way of ELB listening and forwarding multiple ports?

I have added listener for port 80,443 and 8000 in my ELB. Please help


回答1:


Classic ELB

Using the "classic" ELB you can define custom rules for forwarding the ports in the AWS dashboard:

Mind that the requests will be forwarded to all the available instances, which means in the example above (supposing php is running on the 80, node.js on the 8000) all the instances must have both the services running. If the services are instead on different instances you will need two different load balancers, one per port.

Application ELB

Another option is to use an "application" ELB (ALB). This option will allow to have single load balancer with fine-grained rules that will allow, for each protocol, to forward the request to a set of instances.

  • create a "default" ALB
  • add a new target group (see entry under the Load Balancing section in the sidebar) listening on your custom port
  • register the instances running your node.js application (right click on the target group)
  • bind the target group to the listeners of your ALB

Another solution could be, specifying path-based rules, to use only one port (443) and forward only the requests under /to_nodejs to the port 8000.



来源:https://stackoverflow.com/questions/46562925/aws-forward-port-8000-from-elb-to-port-8000-of-ec2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!