.net Core X Forwarded Proto not working

后端 未结 2 1811
离开以前
离开以前 2020-12-14 17:07

I am working to get my .net core 1.1 application working behind a load balancer and enforcing https. I have the following setup in my Startup.cs

public void          


        
2条回答
  •  忘掉有多难
    2020-12-14 18:02

    If you are using a load balancer, it is common to have the load balance terminate the SSL connection and send the request to your application over HTTP.

    This worked for me. I am using SSL termination on AWS Load Balancer.

    app.UseForwardedHeaders(new ForwardedHeadersOptions
    {
        ForwardedHeaders = ForwardedHeaders.XForwardedProto
    });
    

    What this does is updates the Request.Scheme with the X-Forwarded-Proto header so that all redirects link generation uses the correct scheme.

    X-Forwarded-Proto: The scheme from the original client and proxies.

提交回复
热议问题