Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need documentation for enabling HTTPS on Linux / OS X #1198

Closed
SteveSandersonMS opened this issue May 9, 2016 · 8 comments
Closed

Need documentation for enabling HTTPS on Linux / OS X #1198

SteveSandersonMS opened this issue May 9, 2016 · 8 comments
Assignees
Labels
Pri2 Priority 2

Comments

@SteveSandersonMS
Copy link
Member

SteveSandersonMS commented May 9, 2016

The docs at http://docs.asp.net/en/latest/publishing/linuxproduction.html describe how to set up a reverse-proxy from nginx, and they hint that you can do this to enable HTTPS. However, they don't provide any explicit instructions.

If you just add the minimal nginx config to enable SSL, i.e.,

server {
    listen       443;
    ssl                  on;
    ssl_certificate      ssl/nginx.crt;
    ssl_certificate_key  ssl/nginx.key;
    ... other stuff ...
}

... then it will appear to work, but there's a subtle problem. ASP.NET won't know the requests are being served over HTTPS, and so it won't know to do anything that it normally does over HTTPS (such as mark auth cookies as SSL-only).

I understand there's some sort of ASP.NET Core middleware you're supposed to enable, or HTTP headers you're meant to configure in nginx. This should be made clear in docs.

@danroth27 danroth27 added this to the 1.0.0-rc2 milestone May 11, 2016
@danroth27 danroth27 added the Pri2 Priority 2 label May 19, 2016
@dlebedynskyi
Copy link

having similar problem as well. There is Kestrel.https package but it lacks documentation.

@Rick-Anderson
Copy link
Contributor

migrated to #1251

@shirhatti
Copy link
Contributor

@Rick-Anderson Hmm. I haven't verified this. I'm reopening the bug for now. I'll close after I'm able to verify this is no longer needed.

@shirhatti shirhatti reopened this Jul 11, 2016
@Rick-Anderson
Copy link
Contributor

@shirhatti actually I just migrated it to #1251 but we'll keep it open.

@tdykstra tdykstra modified the milestones: Backlog, 1.0.0 Dec 5, 2016
@spboyer spboyer self-assigned this Dec 15, 2016
@spboyer
Copy link
Contributor

spboyer commented Jan 3, 2017

Issue is dated, however looking at what we have now documented for nginx and Apache is well documented for what is needed in the reverse proxy. For ASP.NET Core to know that the request are SSL and/or to listen on 443. The following must be added.

NuGet package Microsoft.AspNetCore.Kestrel.Https

and in WebHostBuilder add

    var host = new WebHostBuilder()
    .UseKestrel(options => 
     {
          options.UseHttps("MyCert.pfx", "MyPassword");
     })
    .UseUrls("http://localhost:5000", "https://localhost:5001");

cc:\ @blowdart

@SteveSandersonMS
Copy link
Member Author

@spboyer I'm not sure adding that code addresses the issue, which is that if you're reverse-proxying from HTTPS to HTTP, then ASP.NET is taking requests on HTTP, and hence won't flag cookies to the browser as HTTPS-only.

Isn't there a way to tell ASP.NET that even though a certain request is coming in on HTTP, that it should be treated as a secure connection, since it is secure beyond the reverse-proxy?

@spboyer
Copy link
Contributor

spboyer commented Jan 6, 2017

@SteveSandersonMS I believe that by adding the XForwardedProto option on UseForwardedHeaders middleware will solve this.

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

See: #2384 (comment) from @Tratcher

@SteveSandersonMS
Copy link
Member Author

Excellent - that's exactly the functionality I was hoping for. And I see it's mentioned at https://docs.microsoft.com/en-us/aspnet/core/publishing/linuxproduction now too!

Closing because I think all the points here are now addressed, but please reopen if you disagree!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Pri2 Priority 2
Projects
No open projects
Development

No branches or pull requests

7 participants