I have a question I'm pretty sure many people will be able to answer without me having to scratch my head.
I have a single public IP, and 2 internal servers that are servicing containers behind a private IP.
Each of the 2 servers are intended to serve a different domain name:
Public IP (*.domain1.com and *.domain2.com in the DNS)
/ \
Server1(domain1) Server2(domain2)
As I'm not a magician, ports 80 & 443 can only be redirected to a single server. Is there a simple way for me to have traefik on server1 servicing domain1 and redirecting everything for domain2 to server 2 ? Would that be a simple router? How can I achieve that easily (and I have multiple subdomains, so it really needs to send to server2 all the requests with *.domain2.com).
This is exactly what a reverse proxy like Traefik is used for. Note that it's not "redirect", as a redirect is a response to a (browser) client to request a different URL. It's "proxy" or "forward" a request.
Run Traefik in a Docker container (note that command is "static" config):
This simple example opens ports http/80 and https/443 and automatically creates TLS certs with LetsEncrypt for the domains used in Host(). You need more complicated dnsChallenge to create wildcard certs.
Note that by default passHostHeader is true for every service. Change this if your target service expects the host name as in the Traefik service URL it is called by.
It's recommended to change the dashboard passwords before deploying this to a production site Or remove dashboard router and service completely.
OK I'm sorry I didn't present myself enough
I'm not looking to know if Traefik can be a good fit for my servers / domains.
I am already running traefik running on each server, each of them servicing with labels on the containers.
My point is that I want from the traefik on server1 to redirect *.domain2.com to the traefik on server2, while conserving the name, because the traefik on server 2 will need that name to service the appropraite container. If I proxy that to the first server, I'm not sure on how the 2nd traefik will behave.
I want the request to be forwarded, as the second server has routers and everything is setup to understand the name of domain2, not domain1.
EDIT to be as clear as possible, this is what I want:
Request comes for siteA.domain1.com > router > server1 traefik > siteA container
Request comes for siteB.domain2.com > Router > Server1 traefik > Server2 traefik > siteB container