ThreeMammals / Ocelot

.NET API Gateway
https://www.nuget.org/packages/Ocelot
MIT License
8.38k stars 1.64k forks source link

HTTP-HTTPS #1651

Closed KreiosX closed 1 year ago

KreiosX commented 1 year ago

Expected Behavior / New Feature

200

Actual Behavior / Motivation for New Feature

404

Steps to Reproduce the Problem

.NET 7, HTTP configuration (HTTPS configure selected at project creation) // UseHttpsRedirection -commented out

this is basic template I use, it works I have 200 result from gateway with HTTP on same configuration, nothing chances except ocelot configuration.. I have made a small research that doesn't have dependcy on it. { "Routes": [ { "DownstreamPathTemplate": "/api/User/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "user", "Port": 80 } ], "UpstreamPathTemplate": "/api/user/{everything}", "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ] }, { "DownstreamPathTemplate": "/api/identity/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "identity", "Port": 80 } ], "UpstreamPathTemplate": "/api/identity/{everything}", "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ] } ], "GlobalConfiguration": { "BaseUrl": "http://localhost:5000" } } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Here is the advanced ocelot I use to test however, 404. I couldn't go further. { "Routes": [ { "DownstreamPathTemplate": "/api/User/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "user", "Port": 80 } ], "UpstreamPathTemplate": "/api/user/{everything}", "UpstreamHttpMethod": [ "Get" ], "LoadBalancerOptions": { "Type": "LeastConnection" }, "RetryPolicyOptions": { "RetryCount": 3, "DurationToWaitBetweenRetriesInMs": 100 }, "RateLimitOptions": { "ClientWhitelist": [], "EnableRateLimiting": true, "Period": "1m", "Limit": 60 }, "QoSOptions": { "TimeoutValue": 5000, "ExceptionsAllowedBeforeBreaking": 3 }, "FileCacheOptions": { "TtlSeconds": 300, "Region": "UserCache" } }, { "DownstreamPathTemplate": "/api/identity/{everything}", "DownstreamScheme": "http", "DownstreamHostAndPorts": [ { "Host": "identity", "Port": 80 } ], "UpstreamPathTemplate": "/api/identity/{everything}", "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ], "LoadBalancerOptions": { "Type": "LeastConnection" }, "RetryPolicyOptions": { "RetryCount": 3, "DurationToWaitBetweenRetriesInMs": 100 }, "RateLimitOptions": { "ClientWhitelist": [], "EnableRateLimiting": true, "Period": "1m", "Limit": 60 }, "QoSOptions": { "TimeoutValue": 5000, "ExceptionsAllowedBeforeBreaking": 3 }, "FileCacheOptions": { "TtlSeconds": 300, "Region": "IdentityCache" } } ], "GlobalConfiguration": { "BaseUrl": "http://localhost:5000" } }

Specifications

raman-m commented 1 year ago

Your description is not informative!

I believe the issue is related to your configuration files, not to implemented functionality in the core. Please note, wrong configuration leads to wrong behavior!

Please, provide a real proof that Ocelot core generates errors or behaves in a wrong way!

KreiosX commented 1 year ago

Only changes that I made, I provided. However result changes. 200 to 404.

raman-m commented 1 year ago

3 days to provide good description of the problem...

KreiosX commented 1 year ago

I have just created new project and configured Ocelot gateway, when I configure it for the first template I provided, it works. When I update my ocelot configuration with the second one I provided, it does not work. I made a small research that maybe the functionalities(Load balancing,QoS,Cache and so) I added requires HTTPS however it does not have dependency on it. So, ocelot configuration I keep in the root as ocelot.json, I provided both. Only changes are made in the application are there which are ocelot.json files.

Note: I specifically marked, I created API HTTPS configured and I disable from Program.cs HttpsRedirection.

raman-m commented 1 year ago

Too many words!

You have to create public repository in GitHub with your draft solution. And maybe the community will help you. So, you have to show your code!

As for me I expect wrong setup of gateway project on your side. Please, read Ocelot documentation, page by page, and provide correct configuration.

raman-m commented 1 year ago

Steps to Reproduce the Problem

First, It is hard to read your configuration JSON! Please, insert JSON-code block with well formatting!

Second, If the 1st basic config works, I would suggest you to add Ocelot features one by one and ensure that new ocelot.json version is really valid, and gateway works without problems. What I see, that your second "advanced" version is full of Ocelot features. But how to recognize what feature breaks the behavior? Note that even a small typo in formatting can lead to broken Ocelot pipeline! So, you have to ensure:

Finally, It is better to publish your draft solution to a GitHub repo.

raman-m commented 1 year ago

From KreiosX's reply on May 4, 2023:

I have just created new project and configured Ocelot gateway, when I configure it for the first template I provided, it works. When I update my ocelot configuration with the second one I provided, it does not work. I made a small research that maybe the functionalities(Load balancing,QoS,Cache and so) I added requires HTTPS however it does not have dependency on it. So, ocelot configuration I keep in the root as ocelot.json, I provided both. Only changes are made in the application are there which are ocelot.json files.

Note: I specifically marked, I created API HTTPS configured and I disable from Program.cs HttpsRedirection.

Hi Asil ! How things are going? Are you still experimenting with Ocelot configs? :smiley_cat:

Usually your issue is not an issue of Ocelot because it is related to valid/invalid configuration of your gateway .NET project. I believe Ocelot features are protocol agnostic, I mean, not related to the DownstreamScheme option at all. So, it is not related to HTTP, HTTPS schemes.

To help you, you need to choose one ocelot.json config. And provide well-formatted JSON code block in a message.

After that, As I suggested in the previous message, you need to isolate Ocelot feature which doesn't function. So, we cannot discuss your "advanced" config because it is full of Ocelot features. We must isolate one broken feature.

Finally, if we will be lucky, and you will show that Ocelot feature is broken with some configs, the issue will be accepted for development and fixing.

Asil, are you still facing the problem?

P.S. Please note! The issue will be closed in a week in case of absent reply from you.