L7 service router / hostname based routing


I read the last update at the issue #1042. Is it possible to use it as hostname based router / frontside proxy? I need a proxy for exposed http/s ports.

http(s)://domain1.com -> container “web1” port 80 / 443
http(s)://domain2.com -> container “web2” port 80 / 443

Yes, that’s what it’s for. You can map hostnames (the Host header) and/or the request path (domain.com/thing1 vs domain.com/thing2) to different containers.

https:// support is not in yet, that will be in the next couple weeks. It will do SSL termination so you would configure the cert(s) to use on the load balancer, rather than having to get them in every web container. The request would then be routed to the approriate web{1,2} over port 80 (in an encrypted IPSec tunnel if crossing hosts).

Hi vincent,

is there an example config?
How to map a domain / path to a container?

During load balancer creation I can choose targets (container), but how to set the domain / path for mapping?

I have installed RancherOS 0.3.3 and latest server / agent. Anything else to update to get this new feature?

It is currently only in the v0.27.0-rcX tags. latest is v0.25.X but should be moved to a new v0.27.0 tag later today. You’ll see it:

1 Like

Actually, to be clear, we will most likely tag this week’s release to 0.28.0

Thanks, @vincent and @willchan !
I’ll test it :smile:

This seems not as flexible as the previous LB configuration, for example I have a containers that run multiple ports for different services (note: this is not a HTTP application).

Previously I would configure my LB like such:

  - '2525:25/tcp'                                                                                                                                                  
  - '1143:143/tcp'                                                                                                                                                  
  - '1995:993/tcp'                                                                                                                                                  
  - '1993:993/tcp'                                                                                                                                                  
  tty: true                                                                                                                                                         
  image: rancher/load-balancer-service                                                                                                                              

That worked well…

Am I correct in assuming I now need to configure multiple LBs to continue this patten?


v0.28.0 has been tagged to latest and has hostname based routing.

1 Like

@noeleon The changes related to hostname based routing are optional fields to extend current capabilities in load balancers.

Your configuration will not have to change and will continue to work as expected.

The existing yml should be backwards compatible, to get the new features there are new labels: http://docs.rancher.com/rancher/rancher-compose/#load-balancer

Phew… That’s good to know! Thanks

I’ve been struggling with these changes, actually no it doesn’t seem to work the way it did before…

my config:

  - 1110:110/tcp
  - 1143:143/tcp
  tty: true
  image: rancher/load-balancer-service
  - proxy:proxy
  stdin_open: true
  - "io.rancher.scheduler.affinity:host_label=lb=true"

on v0.25.0 this would sent traffic from my hosts on port host:1110 -> container:110, host:1143 -> container:143 on the ‘proxy’ service.

Now on 0.28.0 it’s reporting
ERRO[0000] Failed to start: LB : Failed to find target ports for proxy, add label io.rancher.loadbalancer.target.proxy

so when I add the target label(s)? it doesn’t map the services correctly:

  • “io.rancher.loadbalancer.target.proxy=143”
  • “io.rancher.loadbalancer.target.proxy=110”

–this should be imap:
telnet 1143
Connected to
Escape character is ‘^]’.
+OK aee77c32ec44 pop3 Ready

this should be pop3:
telnet 1110
Connected to
Escape character is ‘^]’.
+OK aee77c32ec44 pop3 Ready

I tried playing with the dns aliases but ended up nowhere - no containers get associated to the LB and noting happens.

The example http://docs.rancher.com/rancher/rancher-compose/#load-balancer seems incomplete also, there are no linked services in the LB.

any help would be much appreciated at this stage.

thanks for testing the feature.

based on yours and other users’ feedback, we are going to add backward compatibility to support previous syntax for defining load balancer rules to the next release

@noeleon, Our current release has the previous syntax supported for load balancers.

But you should convert to the new syntax when possible :smile: it supports more than the old one: http://docs.rancher.com/rancher/rancher-compose/rancher-services/#load-balancer

Thank you - 0.30.0 + new syntax is again working for me.

Much appreciated. thanks @vincent @denise