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

Adding Adittional Backends#99

Merged
tifayuki merged 3 commits intodocker-archive:masterfrom
matiasdecarli:master
Nov 3, 2016
Merged

Adding Adittional Backends#99
tifayuki merged 3 commits intodocker-archive:masterfrom
matiasdecarli:master

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:

@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

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

5 participants