# L7 service router / hostname based routing

**URL:** <https://forums.suse.com/t/l7-service-router-hostname-based-routing/88>\
**Category:** Rancher 1.x\
**Created:** [July 15, 2015, 6:14pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88 "2015-07-15T18:14:10Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![pwFoo](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/pwfoo/32/2884_2.png) [@pwFoo](https://forums.suse.com/u/pwFoo)\
**Post date:** [July 15, 2015, 6:14pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/1 "2015-07-15T18:14:10Z")

</div>

[https://github.com/rancher/rancher/issues/1042](https://github.com/rancher/rancher/issues/1042)

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

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [July 15, 2015, 6:29pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/2 "2015-07-15T18:29:24Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![pwFoo](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/pwfoo/32/2884_2.png) [@pwFoo](https://forums.suse.com/u/pwFoo)\
**Post date:** [July 15, 2015, 6:48pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/3 "2015-07-15T18:48:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [July 15, 2015, 6:51pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/4 "2015-07-15T18:51:54Z")

</div>

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:

 ![](https://us1.discourse-cdn.com/flex022/uploads/suse/original/1X/da5c4f7da4f0a86205240f5f4b2f3a2f2faeeb49.png)

---

<div class="post-metadata">

**Author:** ![willchan](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/willchan/32/2856_2.png) [@willchan](https://forums.suse.com/u/willchan)\
**Post date:** [July 15, 2015, 6:53pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/5 "2015-07-15T18:53:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![pwFoo](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/pwfoo/32/2884_2.png) [@pwFoo](https://forums.suse.com/u/pwFoo)\
**Post date:** [July 15, 2015, 7:08pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/6 "2015-07-15T19:08:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![noeleon](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noeleon](https://forums.suse.com/u/noeleon)\
**Post date:** [July 16, 2015, 11:55am UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/7 "2015-07-16T11:55:36Z")

</div>

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:

```
SERVICESLB:                                                                                                                                                       
  ports:                                                                                                                                                            
  - '2525:25/tcp'                                                                                                                                                  
  - '1143:143/tcp'                                                                                                                                                  
  - '1995:993/tcp'                                                                                                                                                  
  - '1993:993/tcp'                                                                                                                                                  
  tty: true                                                                                                                                                         
  image: rancher/load-balancer-service                                                                                                                              
  links:                                                                                                                                                            
  - SERVICESPROXY016:SERVICESPROXY016   

```

That worked well…

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

Thanks

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [July 16, 2015, 6:37pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/8 "2015-07-16T18:37:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [July 16, 2015, 6:38pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/9 "2015-07-16T18:38:58Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [July 16, 2015, 8:24pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/10 "2015-07-16T20:24:02Z")

</div>

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](http://docs.rancher.com/rancher/rancher-compose/#load-balancer)

---

<div class="post-metadata">

**Author:** ![noeleon](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noeleon](https://forums.suse.com/u/noeleon)\
**Post date:** [July 16, 2015, 10:22pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/11 "2015-07-16T22:22:40Z")

</div>

Phew… That’s good to know! Thanks

---

<div class="post-metadata">

**Author:** ![noeleon](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noeleon](https://forums.suse.com/u/noeleon)\
**Post date:** [July 18, 2015, 3:17pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/12 "2015-07-18T15:17:03Z")

</div>

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

my config:

```
LB:
  ports:
  - 1110:110/tcp
  - 1143:143/tcp
  tty: true
  image: rancher/load-balancer-service
  links:
  - proxy:proxy
  stdin_open: true
  labels:
  - "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 172.17.8.100 1143  
Trying 172.17.8.100…  
Connected to 172.17.8.100.  
Escape character is ‘^]’.  
+OK aee77c32ec44 pop3 Ready

this should be pop3:  
telnet 172.17.8.100 1110  
Trying 172.17.8.100…  
Connected to 172.17.8.100.  
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](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.

---

<div class="post-metadata">

**Author:** ![alena](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/alena/32/50_2.png) [@alena](https://forums.suse.com/u/alena)\
**Post date:** [July 21, 2015, 12:30am UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/13 "2015-07-21T00:30:16Z")

</div>

@noeleon  
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

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [July 28, 2015, 12:07am UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/14 "2015-07-28T00:07:54Z")

</div>

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

> **[rancher/rancher](https://github.com/rancher/rancher/releases/tag/v0.30.0)**
>
> Complete container management platform. Contribute to rancher/rancher development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [July 28, 2015, 2:21am UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/15 "2015-07-28T02:21:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![noeleon](https://avatars.discourse-cdn.com/v4/letter/n/0ea827/32.png) [@noeleon](https://forums.suse.com/u/noeleon)\
**Post date:** [July 28, 2015, 7:26am UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/16 "2015-07-28T07:26:06Z")

</div>

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

Much appreciated. thanks @vincent @denise

---

<div class="post-metadata">

**Author:** ![denise](https://avatars.discourse-cdn.com/v4/letter/d/82dd89/32.png) [@denise](https://forums.suse.com/u/denise)\
**Post date:** [July 28, 2015, 9:01pm UTC](https://forums.suse.com/t/l7-service-router-hostname-based-routing/88/17 "2015-07-28T21:01:34Z")

</div>

Closed on July 28, 2015, 9:01pm UTC


