reverse-proxy icon indicating copy to clipboard operation
reverse-proxy copied to clipboard

Requests going to routes not specified with different host address.

Open Octania opened this issue 2 years ago • 3 comments

I have a simple config like below. When I enter the following address: https://localhost:5678/meow/helloworld Then it is routed https://localhost:5678. I am confused because I am under the impression that meow/helloworld will only be routed to https://localhost:1234. Is this a normal behavior? If we have specific hosts listed, shouldn't the route go to the specified hosts for its section? This route meow/helloworld should never go to this host: https://localhost:5678.

    "ReverseProxy": {
        "Routes": {
            "route1": {
                "ClusterId": "cluster1",
                "Match": {
                    "Path": "meow/helloworld",
                    "Host": [ "https://localhost:1234" ]
                },
                "Transforms": [ { "PathRemovePrefix": "/meow" } ]
            },
            "route2": {
                "ClusterId": "cluster2",
                "Match": {
                    "Path": "roar/goodbyworld",
                    "Host": [ "https://localhost:5678"]
                },
                "Transforms": [ { "PathRemovePrefix": "/roar" } ]
            }
        },
        "Clusters": {
            "cluster1": {
                "Destinations": {
                    "destination1": {
                        "Address": "destination1"
                    }
                }
            },
            "cluster2": {
                "Destinations": {
                    "destinatio2": {
                        "Address": "destination2"
                    }
                }
            }
        }
    }

Octania avatar Apr 05 '23 02:04 Octania

Host should be Hosts. https://microsoft.github.io/reverse-proxy/articles/config-files.html

Also, the Hosts field matches the incoming host header, it does not specify the outgoing destination.

Tratcher avatar Apr 05 '23 18:04 Tratcher

We don't currently have schema validation to tag unknown fields which would flag this case. Adding to the backlog.

samsp-msft avatar Apr 06 '23 16:04 samsp-msft

We could add a JSON schems file to https://www.schemastore.org/json/. This is what VS uses in appSettings.json today.

davidfowl avatar May 15 '23 07:05 davidfowl