Google cloud load balancer port 80, to VM instances serving port 9000

被刻印的时光 ゝ 提交于 2019-12-22 09:36:45

问题


I'm new in GCE, and I am confused about setting up the load balancer.

If I have two instances, serving on Port 9000, I want to setup a balancer that accepts on port 80, then route requests to my instances in port 9000..

a diagram like this..

LB:port:80 -> VM:port:9000

I have other load balancers from other providers which has a settings like pointing to VM's port. but in GCE, I cant seem to find it, or I am missing something..

I hope I am making a sense, here. thank you in advance


回答1:


It isn't possible in GCE to do a port rewriting. As a workaround I use port forwarding using iptables Then in GCE, you can create a health check on port 9000, your target pool will have your instances listing on port 9000 and your forwarding rule will be on port 80 with your target pool.

Another workaround will be to run HAProxy on the instance to locally forward port 80 on the instance to port 9000.




回答2:


If your app is HTTP-based (looks like it), then please have a look at the new HTTP load balancing announced in June. It can take incoming traffic at port 80 and forward to a user-specified port (eg. port 9000) on the backend. The doc link for the command is here:

https://developers.google.com/compute/docs/load-balancing/http/backend-service#creating_a_backend_service

Hope it helps.



来源:https://stackoverflow.com/questions/24656161/google-cloud-load-balancer-port-80-to-vm-instances-serving-port-9000

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