byjg / docker-easy-haproxy

Discover services and create dynamically the haproxy.cfg based on the labels defined in docker containers or from a simple static Yaml
MIT License
55 stars 12 forks source link

question about redirects #8

Closed dtenenba closed 2 years ago

dtenenba commented 3 years ago

Hi, this is not an issue but a question -

If a request comes in for a host (say foo.com) on port 80 I want to redirect it to port 443, so I want to redirect

http://foo.com to https://foo.com

How can I do this with easy-haproxy? I will be using a stack and so setting up my labels in my yml file. Thanks for this nice tool!

byjg commented 3 years ago

Hi, yes it is possible :)

You need to use the label: easyhaproxy.redirect.[definition]

and set:

domain1--redirect1,domain2--redirect2

For the example you set, redirect http://foo.com to https://foo.com you should add the following labels:

byjg commented 3 years ago

I am closing this issue :)

josegonzalez commented 2 years ago

This is now done differently right?

byjg commented 2 years ago

Yes, with the new version the redirect becomes a JSON:

easyhaproxy.example.redirect='{"foo.com":"https://foo.com"}'