0
votes

i have these rules:

[backends]
  [backends.pma]
    [backends.pma.servers.server1]
    url = "http://phpmyadmin:80"
  [backends.rabbitmq]
    [backends.rabbitmq.servers.server1]
    url = "http://rabbitmq:15672"

[frontends]
  [frontends.pma]
  backend = "pma"
    [frontends.pma.routes.test_1]
    rule = "Host:pma.example.it"
    passHostHeader = true
  [frontends.rabbitmq]
  backend = "rabbitmq"
    [frontends.rabbitmq.routes.test_1]
    rule = "Host:pma.example.it;Path:/rabbitmq"

The host pma.example.it work, i see phpmyadmin, the host pma.example.it/rabbitmq not work, i have {"error":"Object Not Found","reason":"Not Found"}.

But, from traefik container if I type curl http://rabbitmq:15672 it work's. Any ideas?

4
I have tried but have 404, I see in Firefox development tools http://pma.example.it/start.js instead of http://pma.example.it/rabbitmq/start.jshellb0y77

4 Answers

2
votes

Could you try to use PathPrefix instead of Path as rule.

Note, you have a small typo in your configuration:

[backends]
  [backends.pma] # <---
  [backends.pma.servers.server1]
    url = "http://phpmyadmin:80"

[backends.rabbitmq] # <---
  [backends.rabbitmq.servers.server1]
    url = "http://rabbitmq:15672"

[frontends]
  [frontends.pma]
  backend = "pma"
    [frontends.pma.routes.test_1]
    rule = "Host:pma.example.it"
    passHostHeader = true
  [frontends.rabbitmq]
  backend = "rabbitmq"
    [frontends.rabbitmq.routes.test_1]
    rule = "Host:pma.example.it;Path:/rabbitmq"
1
votes

The path in your two examples aren't equal. When you go to pma.example.it/rabbitmq, your RabbitMQ instance is effectively receiving rabbitmq:15672/rabbitmq, and returning the Object Not Found error.

You probably want PathPrefixStrip instead of Path in your frontend rule. It'll match on paths beginning with /rabbitmq, and strip that before passing it to the backend.

rule = "Host:pma.example.it;PathPrefixStrip:/rabbitmq"
1
votes

PathPrefixStrip won't work, because the main page of management console loads static files using the stripped url, causing responses with status 404. I had similar problem and fixed it by setting path prefix in rabbitmq.conf. In your case it would be:

management.path_prefix = /rabbitmq

The configuration of Traefik stays unchanged.

See also https://www.rabbitmq.com/management.html#path-prefix

-3
votes

There is a missing line in backend config

[backends]
   [backends.pma]
   [backends.pma.servers]      # <----------add this
      [backends.pma.servers.server1]
         url = "http://phpmyadmin:80" 

(same for backend.rabbitmq)