That makes my http based service available via HTTPs / LetsEncrypt on the domain host.domain.com and HTTP-requests are automatically redirected to HTTPs which is exactly what I want.
I need to extend this setup to listen on an additional domain-name, let's assume it is secondary.domain.com. I also want HTTPs encryption via LetsEncrypt for this host name but I want to redirect everything targeting this domain to host.domain.com no matter if the request comes in over http (80) or https (443).
Is this possible?
If so, how can I achieve that?
Hi @ldez, thank you for your reply,
I will check your config example in my actual setup. However there are two things that from my understanding do not match my requirements:
=> Your http-catchall router would react on any HTTP request, correct? What I need instead is to listen only for the hostnames host.domain.com (A) and secondary.domain.com (B).
=> With the parameter
from your example the service would be available at both domain names with HTTPs which is fine so far. However I can't see that a request on B would be redirected to A which is a requirement in my case.
I apologize in case I did not understand your solution correct.
My requirements are in the last paragraph of my initial post. In other words:
I want my service to be available at A with automatic redirect from http to https (working).
I want all requests at B to be redirected to A for http and https.
Hi @ldez,
thank you very much for your updated config and sorry for coming back to this topic that late but I'm still struggling.
First thing I noticed was that I had to replace the colons ":" with equal signs "=" to make it work with the labels in my docker-compose.yml.
However, I get this error message when I try a docker-compose up:
ERROR: yaml.scanner.ScannerError: while scanning a double-quoted scalar
in "./docker-compose.yml", line 158, column 15
found unknown escape character '.'
in "./docker-compose.yml", line 158, column 91
Then the error does not show up anymore. However, no routers, services or middlewares are registered and the site does not respond at the defined domains.
When I comment out the redirect_regex middleware and remove the references from rweb and rwebs the site is reachable under both domain names. Of course the redirect is missing.
Maybe I just can't figure out how to escape the regex correctly.
Any idea?
Hi @ldez, thank you I was not aware of this. I would also prefer the second syntax, but it doesn't matter that much to me as long as it is consistant and words.
Anyways, do you have any idea why the yaml.scanner complained about the regex and how to escape it correctly?