Help with traefik redirecting traffic to baremetal apache

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

lpallard

Member
Aug 17, 2013
280
12
18
Hello,

So I've got Apache running baremetal on a VPS and serving two sites that I cant containerize (one of them being a Coppermine gallery which the devs have refused (for good reasons I am sure) to not containerize)...

I've also got some docker containers running on the same VPS. Wanting to use traefik as a reverse proxy to serve the containers with FQDN's, I installed it, and configured it, and it works flawlessly! I can access containers using:

Code:
container.server_fqdn
Since Traefik uses port 80 I had to change the ports Apache binds to. OK I can access the "baremetal" sites via:

Code:
http://server_fqdn:8080/site1
However its ugly. I'd like to have traefik handle the routing and sends traffic to apache. This is what I've done so far:

1. Configured Apache to bind to ports 80 & 443 on host;
2. Added this block in my traefik.yaml:

Code:
entryPoints:
  web:
    address: :80
    middlewares:
      - redirect-to-apache
 
    middlewares:
      redirect-to-apache:
        redirectRegex:
          regex: "^http://(.*)\.localhost"
          replacement: "http://localhost:8080/${1}"

  websecure:
    address: :443
My understanding of this is that traefik will use the "redirect-to-apache" middleware on http (80) to route (using regex) from "http://blabla.localhost" to "http://localhost:8080/blabla" which is identical to manually accessing the baremetal apache sites...

Problem is when I try to access (for example) my Coppermine gallery using

"http://coppermine.server_fqdn"

I get

Code:
404 page not found
And nothing is shows in traefik's logs (which I find a bit strange since its running with log level=DEBUG)...

All right if someone knows how to make this work I'd like to hear!
Thanks!