How to configure Ocelot to prevent it from adding the port to my downstream URL? #1750
Replies: 4 comments 4 replies
-
Hi Walisson! As far as I understood, Ocelot substitutes downstream port by upstream port when there is no downstream port. Correct? On my opinion, when there is no specified downstream port, so a warning should be logged.
|
Beta Was this translation helpful? Give feedback.
-
Just define the downstream port for all routes! For example: {
"Routes": [
{
// Route 1
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "route1.com",
"Port": 80
}
],
// ...
},
{
// Route 2
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "route2.com",
"Port": 443
}
],
// ...
},
],
"GlobalConfiguration": {
}
} Let me know testing results please! |
Beta Was this translation helpful? Give feedback.
-
Answering your question
I suggested you just specify Port value explicitly as is done for all routes now as the default behavior. Regarding potential bug of port substitution from upstream... Still need to check it... Haven't you received validation errors 7 warning in the log? Also, I've looked into the code, the DownstreamRequestCreator class, and it has no extra logic related to Have I answered on your question? |
Beta Was this translation helpful? Give feedback.
-
@walissonde It could be a bug, it can be a feature, I'm not sure now. Historically all routes should have specified port. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I am currently working on a Proof of Concept (POC) using Ocelot, but I have encountered an issue when making a URL call from localhost to route traffic to my API.
Is that correct when missing downstream port is replaced with an upstream port?
Actual Behavior
The base URL of my project is:
I also have a downstream URL, for instance:
my-external-api.com
(without specifying any port)However, when I make a call to my URL through the Ocelot gateway, it adds a port to my URL, causing my external API to malfunction because it doesn't expect a port.
Here's what happens:
Expected Behavior
Now, I'm looking for a way to configure Ocelot to ignore this added port (e.g., 5021) when making calls to my API. I've already removed the port from my downstream configuration.
How can I configure Ocelot to resolve this issue and prevent it from adding the port to my downstream URL?
Specifications
Beta Was this translation helpful? Give feedback.
All reactions