How to force all links to use HTTPS instead of HTTP when using SSL Offload
Open
@xuzhg is already working on this.
Since Dec 17, 2019.
question
- Dominant language
- C#
- Stars
- 864
- Forks
- 467
- PR merge metrics
- No merged PRs in 30d
Description
We use ODATA (.net core) in servers behind a load balance where we do SSL Offload, this means that all ODATA API are hit with an http:// url.
I need to conditionally be able to force all urls to use https://.
How can I do it?
I went trough the source code but I could not find any hint on how to do what I need.
For now I wrote a simple middleware as shown below but this is an hack I don't like, and can have unforeseen side effects.
// Middleware used to simulate an https request when behing a load balancer with SSL offloade
app.Use(async (context, next) =>
{
if (context.Request.Headers.ContainsKey("X-Forwarded-Proto"))
{
// The request schema is used by OData to generate all links like, Metadata, Next, GetById and so on
context.Request.Scheme = "https";
}
await next();
});
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.