2

I need to set subdomains for apps in docker containers, not in internal rancher network but for public use. I have domain delegated to rancher server. And there is host property in almost all stacks from catalog, but it doesn't work. I guess i need to delegate domain using some rancher dns or setup nginx to proxy traffic to some rancher server but I can't find any.

MadDocNC
  • 670
  • 5
  • 17

1 Answers1

3

What you need is add a load-balancer service, which then forwards 80/443 of the host to the container app/nginx/whatever.

So navigate to your stack, click on add service -> load balancer. Then you can chose either for wich domain to trigger ( or catch all, which i would do for now ) and then which target. There you select your app-container and the port the container has its app / httpd server running and thats basically it

Eugen Mayer
  • 8,942
  • 4
  • 33
  • 57
  • I can only chose containers from catalog stacks there. And no standalone containers. Am i supposed to run every app in separate stack? – MadDocNC Jan 11 '17 at 12:31
  • 1
    You need a stack to at least deploy your lb to, the lb does not need to be in the stack of the app. Generally speaking, yes you should use a stack per app, this is kinda a design pattern there - but that is also out of scope for this question, i guess – Eugen Mayer Jan 11 '17 at 14:57
  • Ok. I wrapped my containers with stack and added load balancer. But my host machine already has 80 and 443 ports holded by nginx for main domain. Where should i proxy subdomains traffic? Also after setting up balancer on port 80. My host stoped to respond on 80 port. Even via default nginx. – MadDocNC Jan 12 '17 at 16:27
  • Either you have several external IPS to bind to or you need to deploy one single lb and route to all your destinations. You obviously cannot bind port 80/443 twice on one ip – Eugen Mayer Jan 12 '17 at 16:33
  • So if enyone face this problem with dead 80 port. I noticed that rancher use iptables to redirect connection to load balancer. And if you change port on balancer or removed it you also need to restart iptables. – MadDocNC Jan 13 '17 at 10:16