Foreword: I appreciate that this is not ideal, I'm in the process of migrating away from an old Apache-based server, and need to leave a few sites there for now.
I'd like to have Traefik forward certain requests to another server, consider the following config:
[file]
[frontends.attie]
backend = "attie"
[frontends.attie.routes._]
rule = "HostRegexp: {host:^(www\\.)?attie.co.uk}"
[backends.attie.servers._]
url = "http://attie.co.uk:80"
Externally, the DNS points attie.co.uk
at this server. Traefik must then forward the request on to the old server using the Host: attie.co.uk
header.
Unfortunately, the DNS points attie.co.uk
to this server, and we end up in a loop (of course).
I've added entries to the container's /etc/hosts
, but this doesn't work - we still end up in a loop (see the log in this gist), presumably because Traefik is doing name resolution itself and ignoring the hosts file.
I've tried using the customRequestHeaders
to no avail - it appears in the config blob in the log, but doesn't work.
[frontends.attie.headers.customRequestHeaders]
Host = "attie.co.uk"
[backends.attie.servers._]
url = "http://10.42.0.4:80"
Note the warning on this page:
If the custom header name is the same as one header name of the request or response, it will be replaced.
Is there any way I could do one of these?
- Configure the name resolution to consider
/etc/hosts
- Force the backend to connect to a host by giving an IP alongside the
url
- Provide a
Host:
header paired with an IP in the URL
I've had a fairly extensive look at the documentation, but may have missed something.
PS: I would have expected this question to be better suited to ServerFault or SuperUser, but they don't have the traefik tag, and the documentation specifically mentions StackOverflow.