I try to configure spring cloud gateway to forward to the standard ui of HashiCorp Consul under '/consul/ui' or just '/consul'. I however don't get how to do that correctly. Consul is running in standard configuration. I have an external ip address and a local network interface on 10.2.0.2. I tried:
routes:
- id: consul
uri: "http://127.0.0.1:8500"
predicates:
- Path=/consul/
curl -L 127.0.0.1/consul/ui however gives me a 500, since according to the logs the gateway doesn't match /consul but /consul/** and then decides to route to 10.2.0.2:8300 which is Consuls rpc endpoint.
Another try:
- id: consul
uri: "http://127.0.0.1:8500"
predicates:
- Path=/consul/**
filters:
- StripPrefix=1
... did exactly the same as the other one. Another promising approach:
- id: consul
uri: "http://127.0.0.1:8500"
predicates:
- Path=/consul/**
filters:
- RewritePath=/consul/(?<segment>.*), /ui/$\{segment}
Using curl -L actually works on the command line. However, in a browser I only see the consul logo, but the whole page doesn't load.
I've of course also tried some other combinations, none worked.
Note: The consul /ui endpoint delivers a status 302 and then forwards to the actual page.
Note: I use SSL in the gateway.
Note: ssh -N -f -L 8500:localhost:8500 <user>@<host>
allows me to open the expected ui locally under localhost:8500.
UPDATE:
Apparently /consul/**
was a bad choice since consul itself is already registered under this route, thus I had a conflict. This at least makes clear, why cloud gateway tried routing to port 8300.
Unfortunately at present there is no real answer to this question, but some hacky workarounds. However, folks are working on a solution to be able to proxy pass consul ui. See e.g. https://github.com/hashicorp/consul/issues/1382