简体   繁体   中英

Traefik behind Apache proxy

I would like to ask for some help, I have been working with Traefik for 2-3 months, we created an infrastructure with Docker Swarm, took 4 dedicated servers in our cluster and used Traefik as reverse proxy for the containers with a domain.

A few days ago our IT broke and had to recreate it, we got a virtual machine, which is on a dedicated server and handles bunch of VMs too, and here comes the problem. This VM does not have any public IP address, it is behind an apache proxy which handles all the incoming requests on 80 and forwards to the VM where the Traefik runs.

My problem is that our IT was working with Traefik which was connected directly to the internet with a public IP, but I can not configure Traefik to work with behind this Apache proxy, I always get the minimal error message: 404 page not found.

The VM runs CentOS.

If anybody had the same problem and managed a solution please reply, I hope Traefik can work behind Apache proxy. Maybe we just lack some domain/hostname configuration on this VM but I still don't know what to do.

Apparently the Apache in front of traefik is not forwarding the Host header correctly to traefik.

In order to proxy your requests to the correct backend, traefik uses the standard HTTP header Host which basically is the hostname that the end user requested (what he typed in his browser).

If you put apache in front of that and add a proxy rule like the following:

ProxyPass / x.y.z.w
ProxyPassReverse / x.y.z.w

Where xyzw is the IP address of traefik, the Host header will be rewritten by apache to be xyzw .

That means that the original Host requested by the user would be lost and traefik would be enable to proxy correctly.

In order to make Apache preserve the Host header coming from the client when forwarding calls to a proxy, you need to add the following configuration:

ProxyPreserveHost On

Right after the ProxyPass directives.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM