MuleSoft cloudhub provides inbuilt loadbalancer in the form of {appname}.cloudhub.io, which forwards the request on mule-worker-{appname}.au.cloudhub.io:8081, if we are using http port.
When you deploy your application on cloudhub, the app http listener always listens on port 8081 for http and 8082 for https.
This is a step by step guide to set up dedicated loadbalancer on cloudhub.
For creating a dedicated load balancer, first go to load balancer tab and click on create load balancer button.
Now put the load balancer name and select the target VPC, the VPC which you have created for your cloudhub.
Select inbound http mode to redirect so that calls coming as http will automatically redirected to https.
Add your certicates and pem files on the next page.
now load balancer is created with a default rule.
│ Index │ Input URI │ App Name │ App URI │ Upstream Protocol │ ├───────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┼──────────────────────────────┤ │ 0 │ /{app}/ │ {app} │ / │ http │ └───────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┴──────────────────────────────┘it means your load balancer URL which is like this : https://{load-balancer}-dlb.lb.anypointdns.net/{app} will be forwarded to mule-worker-{appname}.au.cloudhub.io:8091 Please note that in case of inbuilt load balancer, the request is forwarded to mule-worker-{appname}.au.cloudhub.io:8081,but in case of a dedicated load balancer it is forwarded to mule-worker-{appname}.au.cloudhub.io:8091 now since we have configured our app to listen to {http.port}, it always listens to port 8081. and dedicated load balancer url will always result in 502 error like this. so, we need to change our app to listen to port 8091. I have tried changing the port by adding the property to cloud hub, but it does not work. You have to change your application to listen to {http.private.port} like this in order to make your dedicated load balancer work:
<http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="${http.private.port}" doc:name="HTTP Listener Configuration"/>Once you do that, dedicated load balancer url will work correctly.