Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Conversation

@matiasdecarli
Copy link
Contributor

This is a PR to add customs backends

The idea behind this is to add the possibility to segment some routes and send them to a different host outside Docker Cloud

For example

frontend www-https
    ...
    #docker-cloud backend routes
    acl host_api path_beg /api
    acl host_api path_beg /route1
    acl host_api path_beg /route2

    use_backend default_service if host_api
    default_backend cdn

backend default_service
    ...

backend cdn
   redirect scheme https code 301 if !{ ssl_fc }
   server s1 <some other host>:<some other port>

Additionally I've created a new flag called FORCE_DEFAULT_BACKEND that could disable the auto default_backend for cases like the example above

Any suggestion will be greatly appreciated

@matiasdecarli matiasdecarli mentioned this pull request Aug 2, 2016
@matiasdecarli
Copy link
Contributor Author

@tifayuki can you give me any feedback on this? Thanks in advance

@tifayuki
Copy link
Contributor

tifayuki commented Sep 5, 2016

@matiasdecarli

Sorry for the late response.
Does your changes only allow one server instruction in the additional backend?

I think we can do this similar to EXTRA_FRONTEND_SETTINGS_<PORT>, using ADDITIONAL_BACKEND_<NAME>, for example:

ADDITIONAL_BACKEND_CDN=redirect scheme https code 301 if !{ ssl_fc }, maxconn 2000, balance source, server s1 <some other host>:<some other port>, server s2 <some other host>:<some other port> check generates

backend CDN
   redirect scheme https code 301 if !{ ssl_fc }
   maxconn 2000
   balance source
   server s1 <some other host>:<some other port>
   server s2 <some other host>:<some other port> check

What do you think?

@matiasdecarli
Copy link
Contributor Author

matiasdecarli commented Sep 5, 2016

@tifayuki Sounds really good. I'll do these two changes in the next couple of days

  • Add the name of the backend on the 'envar' name (example: 'ADDITIONAL_BACKEND_')
  • Add the possibility to add +1 servers to the party 🎉

@gvilarino
Copy link

This looks awesome

@matiasdecarli
Copy link
Contributor Author

@tifayuki Done!

An example of the behaviour

docker run -ti --name <container_name>  -e ADDITIONAL_BACKEND_backend1='redirect scheme https code 301 if !{ ssl_fc }, maxconn 2000, balance source, server s1 192.168.2.1, server s2 192.168.2.2:8888 check' -e ADDITIONAL_BACKEND_backend2='redirect scheme https code 301 if !{ ssl_fc }, maxconn 2000, balance source, server s1 192.168.1.1:8080 check' <container_id>
...
...
...
backend backend1
  redirect scheme https code 301 if !{ ssl_fc }
  maxconn 2000
  balance source
  server s1 192.168.2.1
  server s2 192.168.2.2:8888 check
backend backend2
  redirect scheme https code 301 if !{ ssl_fc }
  maxconn 2000
  balance source
  server s1 192.168.1.1:8080 check

@v13j0
Copy link

v13j0 commented Sep 11, 2016

+1

@neiker
Copy link

neiker commented Sep 11, 2016

This is nice

@gvilarino
Copy link

:shipit:

@roynasser
Copy link

roynasser commented Sep 14, 2016

This would be very useful!! I hope it gets merged soon :)

( @matiasdecarli , is this available on docker hub by any chance so we can already start using your fork?)

Also, one more question, does this work only to add an additional backend to an existing service, or can I create a Backend/Frontend pair for a service which is completely outside of my docker environment? I would like to move my HAProxy into a dockerized infrastructure, but not move all of the services in... Some are already in the docker structure, others like DB, arent, so I basically want to configure a balancing/proxying configuration within the docker-haproxy instance. Is this possible in your branch?

@matiasdecarli
Copy link
Contributor Author

Hi @RVN-BR

Yes, this is available on my personal Docker Hub account if you wanna start testing. Any feedback is welcome

Regarding the "creating extra frontends" thing... I can't see the benefit of doing that, other than having some services running in ports different than 80 || 443. Is this the case? I'm afraid that this excedes the scope of this Pull Request

Let me know if I can help you with anything else

@roynasser
Copy link

Hi @matiasdecarli thanks for the explanation...

Like I said, my use case does depend on having other services, on other ports, and even other protocols routed into a containerized haproxy instance and proxied out to another service (i.e. Redis, DB, etc).

I had initially thought this was what your pull was about (I didnt realize in my head that you were adding backends to EXISTING services, I thought wrongly it was backends and frontends, but it was my mistake)...

Unforuntately I dont have a use for your branch at this moment :( I'll probably need to deploy some other haproxy container image or even just roll out my own (which I kinda didnt wanna do), but we'll see... :)

Thanks for responding!

@matiasdecarli
Copy link
Contributor Author

@tifayuki can we have this merged?

@tifayuki tifayuki merged commit a1a2fbb into docker-archive:master Nov 3, 2016
@tifayuki
Copy link
Contributor

tifayuki commented Nov 3, 2016

@matiasdecarli
Done. The code is included in 1.6.0
Thank you for the contribution :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants