Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpstreamHost not working #1925

Closed
nrllhylmz opened this issue Jan 16, 2024 · 8 comments
Closed

UpstreamHost not working #1925

nrllhylmz opened this issue Jan 16, 2024 · 8 comments
Labels
invalid Not actually an issue

Comments

@nrllhylmz
Copy link

nrllhylmz commented Jan 16, 2024

Hi,

I upgraded ocelot. (18.0.0 -> 22.0.1)
"UpstreamHost" worked without problems in the old version but it doesn't work in the latest version.
Ocelot failed to match routes.
I deleted this feature. Routes matched. But i want to seperate host(UpstreamHost).

Thanks

@raman-m
Copy link
Member

raman-m commented Jan 16, 2024

UpstreamHost not working

Why do you think so? Our unit & acceptance tests are green! 😉


I upgraded ocelot. (18.0.0 -> 22.0.1)

Maybe something wrong with the upgrade process...


Ocelot failed to match routes.

Wow! Please provide more details: ocelot.json file, logs with errors info, and etc.
Which routes? We don't see them! 😉


I deleted this feature. Routes matched. But i want to seperate host(UpstreamHost).

Sorry? What have you deleted and how?

@raman-m raman-m added needs validation Issue has not been replicated or verified yet needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels Jan 16, 2024
@raman-m
Copy link
Member

raman-m commented Jan 16, 2024

@nrllhylmz What's your full name?
Please upload complete solution to your GitHub account for verification and review by our team!

@nrllhylmz
Copy link
Author

nrllhylmz commented Jan 16, 2024

Ocelot 18.0.0 working but Ocelot 22.0.1 not working.
Deleted UpstreamHost. Working. But i want to seperate upstreamhost.

Warnings;

requestId: 0HN0MJFAEUU8F:00000009, previousRequestId: No PreviousRequestId, 
message: 'Error Code: UnableToFindDownstreamRouteError 
Message: Failed to match Route configuration for upstream path: /test/WeatherForecast, verb: GET.
errors found in ResponderMiddleware.
Setting error response for request path:/test/WeatherForecast, request method: GET'
 
requestId: 0HN0MJFAEUU8F:00000009, previousRequestId: No PreviousRequestId, 
message: 'DownstreamRouteFinderMiddleware setting pipeline errors. IDownstreamRouteFinder returned Error Code: UnableToFindDownstreamRouteError 
Message: Failed to match Route configuration for upstream path: /test/WeatherForecast, verb: GET.'

My ocelot.json 👉

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "UpstreamPathTemplate": "/test/{everything}",
      "UpstreamHttpMethod": [
      ],
      "DownstreamHttpMethod": null,
      "AddHeadersToRequest": {
      },
      "UpstreamHeaderTransform": {
      },
      "DownstreamHeaderTransform": {
      },
      "AddClaimsToRequest": {
      },
      "RouteClaimsRequirement": {
      },
      "AddQueriesToRequest": {
      },
      "ChangeDownstreamPathTemplate": {
      },
      "RequestIdKey": null,
     "FileCacheOptions": {
        "TtlSeconds": 0,
        "Region": null
      },
      "RouteIsCaseSensitive": false,
      "ServiceName": null,
      "ServiceNamespace": null,
      "DownstreamScheme": "https",
      "QoSOptions": {
        "ExceptionsAllowedBeforeBreaking": 0,
        "DurationOfBreak": 0,
        "TimeoutValue": 0
      },
      "LoadBalancerOptions": {
        "Type": null,
        "Key": null,
        "Expiry": 0
      },
      "RateLimitOptions": {
        "ClientWhitelist": [
        ],
        "EnableRateLimiting": false,
        "Period": null,
        "PeriodTimespan": 0.0,
        "Limit": 0
      },
      "AuthenticationOptions": {
        "AuthenticationProviderKey": null,
        "AllowedScopes": [
        ]
      },
      "HttpHandlerOptions": {
        "AllowAutoRedirect": false,
        "UseCookieContainer": false,
        "UseTracing": false,
        "UseProxy": true,
        "MaxConnectionsPerServer": 2147483647
      },
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 7071
        }
      ],
      "UpstreamHost": "localhost:6001",
      "Key": null,
      "DelegatingHandlers": [
      ],
      "Priority": 1,
      "Timeout": 0,
      "DangerousAcceptAnyServerCertificateValidator": false,
      "SecurityOptions": {
        "IPAllowedList": [
        ],
        "IPBlockedList": [
        ]
      },
      "DownstreamHttpVersion": null
    }
  ],
  "DynamicRoutes": [
  ],
  "Aggregates": [
  ],
  "GlobalConfiguration": {
    "RequestIdKey": null,
    "ServiceDiscoveryProvider": {
      "Scheme": null,
      "Host": null,
      "Port": 0,
      "Type": null,
      "Token": null,
      "ConfigurationKey": null,
      "PollingInterval": 0,
      "Namespace": null
    },
    "RateLimitOptions": {
      "ClientIdHeader": "ClientId",
      "QuotaExceededMessage": null,
      "RateLimitCounterPrefix": "ocelot",
      "DisableRateLimitHeaders": false,
      "HttpStatusCode": 429
    },
    "QoSOptions": {
      "ExceptionsAllowedBeforeBreaking": 0,
      "DurationOfBreak": 0,
      "TimeoutValue": 0
    },
    "BaseUrl": "https://localhost:6001",
    "LoadBalancerOptions": {
      "Type": null,
      "Key": null,
      "Expiry": 0
    },
    "DownstreamScheme": null,
    "HttpHandlerOptions": {
      "AllowAutoRedirect": false,
      "UseCookieContainer": false,
      "UseTracing": false,
      "UseProxy": true,
      "MaxConnectionsPerServer": 2147483647
    },
    "DownstreamHttpVersion": null
  }
}

@nrllhylmz
Copy link
Author

I delete "UpstreamHost":"localhost:6001" and it worked.
I want to use "UpstreamHost"

@raman-m
Copy link
Member

raman-m commented Jan 16, 2024

@nrllhylmz commented on Jan 16:


I delete "UpstreamHost":"localhost:6001" and it worked.
I want to use "UpstreamHost"

But why do you need to use UpstreamHost if you have single route in development environment?
Maybe some firewall tool will help you? 😄

Read UpstreamHost docs and you will get that feature is based on Host header! You just cannot make request from Ocelot instance app to itself!


Your very zipped JSON

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "UpstreamPathTemplate": "/test/{everything}",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost", "Port": 7071
        }
      ],
      "UpstreamHost": "localhost:6001",
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:6001",
    "DownstreamHttpVersion": null
  }
}

Don't you see the issue?
You cannot use "UpstreamHost" with value localhost:6001 because "BaseUrl" is https://localhost:6001 !!!
You cannot make requests from Ocelot instance to itself!
"UpstreamHost" property is used to filter incoming requests from various domains in DNS form but not from Base URL of Ocelot host & port! It is impossible!
That is why you have error: Failed to match Route configuration for upstream path: /test/WeatherForecast which says that Ocelot cannot find route!

What are you doing? 🤯

@raman-m
Copy link
Member

raman-m commented Jan 16, 2024

Nurullah Yılmaz!

I recommend you to

  • start reading Ocelot docs from very beginning.
  • start using DNS and dev & test API tools like Postman

I see misconfiguration problem which should be fixed by your own.
Our all tests are green and UpstreamHost feature should not be broken.
For invalid configs the feature can be broken.

@raman-m raman-m closed this as not planned Won't fix, can't repro, duplicate, stale Jan 16, 2024
@nrllhylmz
Copy link
Author

nrllhylmz commented Jan 16, 2024

Dear @raman-m
I created a sample project for you.


My ocelot.json

{
	"Routes": [
		{
			"UpstreamHost": "localhost:6001",
			"UpstreamPathTemplate": "/test/{everything}",
			"DownstreamPathTemplate": "/{everything}",
			"DownstreamHostAndPorts": [
				{
					"Host": "localhost",
					"Port": 7071
				}
			]
		},
		{
			"UpstreamHost": "localhost:6002",
			"UpstreamPathTemplate": "/test/{everything}",
			"DownstreamPathTemplate": "/{everything}",
			"DownstreamHostAndPorts": [
				{
					"Host": "localhost",
					"Port": 7072
				}
			]
		}
	],
	"GlobalConfiguration": {
		"BaseUrl": "https://localhost:6001"
	}
}

Projects started

Ocelot18.Api(version 18.0.0) => https://localhost:6001;
			 => https://localhost:6002, 
Test1.Api => https://localhost:7071,
Test2.Api => https://localhost:7072

https://localhost:6001/test/WeatherForecast route matched
https://localhost:6002/test/WeatherForecast route matched

Projects stop


Projects started

Ocelot22.Api (version 22.0.1) => https://localhost:6001;
			 => https://localhost:6002, 
Test1.Api => https://localhost:7071,
Test2.Api => https://localhost:7072

https://localhost:6001/test/WeatherForecast route not found
https://localhost:6002/test/WeatherForecast route not found

Projects stop

Repository link: https://github.com/nrllhylmz/Example

Thanks.

@raman-m raman-m added invalid Not actually an issue and removed needs validation Issue has not been replicated or verified yet needs feedback Issue is waiting on feedback before acceptance waiting Waiting for answer to question or feedback from issue raiser labels Jan 17, 2024
@raman-m
Copy link
Member

raman-m commented Jan 17, 2024

Your next created #1926 will be checked by our QA engineer... You can talk to him.

@ThreeMammals ThreeMammals deleted a comment from nrllhylmz Jan 19, 2024
@ThreeMammals ThreeMammals deleted a comment from nrllhylmz Jan 19, 2024
@ThreeMammals ThreeMammals deleted a comment from nrllhylmz Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Not actually an issue
Projects
None yet
Development

No branches or pull requests

2 participants