0

I have a Wordpress site running as a Docker stack.

If I access it directly through DNAT (using a valid IP address just for this site), everything works well.

If I try to access it through Traefik (so I can share a valid IP address with other HTTP services), I can only access the home page of the site and Wordpress admin pages for this same site but for all other regular pages I get a error message like this:

Unable to connect

Firefox can’t establish a connection to the server at 192.168.109.236.

The other (non-Wordress) sites that share the IP address used by Traefik work just fine. Only this Wordpress driven one has this issue.

The 192.168.109.236 IP address is the address of the Docker worker configured as a backend for this site in Traefik as you can see in this traefik.toml snippet:

 [file]
   [frontends]
     [frontends.site]
       backend = "site"
       [frontends.site.routes.site1]
         rule = "Host:www.EXAMPLE.com,www.EXAMPLE.com.br,EXAMPLE.com,EXAMPLE.com.br"

   [backends]
     [backends.site]
       [backends.site.loadbalancer.stickiness]
       [backends.site.healthcheck]
         path = "/"
         interval = "10s"
       [backends.site.servers.c1]
         url = "http://192.168.109.236:9003"
       [backends.sita.servers.a1]
         url = "http://192.168.109.233:9003"
       [backends.site.servers.a2]
         url = "http://192.168.109.219:9003"

How to make Wordpress links point to site URL instead of Docker worker's IP address when being accessed through Traefik?

1 Answer 1

0

With the help from How to fix Wordpress links not pointing to site URL when being accessed through Traefik? I finally found the solution to make Wordpress play nicelly with Traefik:

passHostHeader = true

so my previous traefik.toml snippet is now:

 [file]
   [frontends]
     [frontends.site]
       backend = "site"
       passHostHeader = true
       [frontends.site.routes.site1]
         rule = "Host:www.EXAMPLE.com,www.EXAMPLE.com.br,EXAMPLE.com,EXAMPLE.com.br"

   [backends]
     [backends.site]
       [backends.site.loadbalancer.stickiness]
       [backends.site.healthcheck]
         path = "/"
         interval = "10s"
       [backends.site.servers.c1]
         url = "http://192.168.109.236:9003"
       [backends.sita.servers.a1]
         url = "http://192.168.109.233:9003"
       [backends.site.servers.a2]
         url = "http://192.168.109.219:9003"

This way Wordpress has the info to do it's internal redirectioning magic without having to use Docker worker's IP.

To find out about passHostHeader and how to set it I had to read both https://docs.traefik.io/basics/ and https://docs.traefik.io/user-guide/examples/ and guess it could help me in this situation as Traefik's documentation, as usual, presents this info in charade form.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .