question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: DownstreamHostAndPorts alias

See original GitHub issue

My team and I are test-driving Ocelot for a new project. We are wondering if it is possible to alias the DownstreamHostAndPorts somehow without having to repeat it for many endpoints. This is especially important to us when we think about overriding host and port per environment.

For example, for development purposes, we want to have Host and Port set to localhost and 5005, but for staging and production to a different host name and port. I understand that this is possible to do via override, but we’d rather not duplicate the entire definition again.

We’d like to define multiple hosts and ports in the global configuration and reference them in the downstream host and ports section.

Example:

"GlobalConfiguration": {
  "BaseUrl": "https://our-system.net/api",
  "RequestIdKey": "X-Request-Id",
  "HostAndPorts": [
    {
      "Alias": "ServiceA",
      "Host": "localhost",
      "Port": "5005"
    }
  ]
}

Then, in the “ReRoutes” config, we’d use it instead of the host definition:

{
  "ReRoutes": [
    // other config
    "DownstreamHostAndPorts": [
      {
        "UseAlias": "ServiceA"
      }
    ]
  ]
}

Is this a use case you have come across? I guess, as a workaround, we could define host names in the hosts file of the system, but that requires all devs to have the same entries.

Specifications

  • Version: 12.0.1
  • Platform: dotnet core 2.1.5

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:8
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
raman-mcommented, Aug 10, 2023

The issue has been accepted due to ready PR #1353 :

All interested parties are welcome to review the code. But the spec above is not final, the discussion can continue…

1reaction
gao-arturcommented, Nov 20, 2020

Check my answer on SO. It does exactly what you are asking for https://stackoverflow.com/a/63601248/2557855

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ocelot configuration always returns not found
It's deployed on IIS with alias. Ocelot is on /gateway and the downstream api on /privacy_api. My configuration is as follows:
Read more >
Ocelot
We are wondering if it is possible to alias the DownstreamHostAndPorts somehow without having to repeat it for many endpoints. This is especially...
Read more >
.Net Core and Docker – solidfish
When doing the “inspect” command, note that its using an alias of “/src” for the source path. The “-w” indicates the 'working directory'...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found