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.

How to use letencrypt with blazor in Linux Web App

See original GitHub issue

Hello,

I’m trying to create enable SSL for my domain in Blazor Server App that is hosted in an azure Web App.

My issue is, that I’m not able to serve /.well-known/ directory and subdirectories with my blazor app.

Web App Information

  • B1 Linux web app
  • Using .net core 3.1.0

Static File Configuration

Here my sample of code that should create and serve the folder.

public static class AcmeChallengeResponderExtensions
    {
        private const string WellKnownFolder = @".well-known";
        private const string WellKnownRequestPath = @"/.well-known";
        private const string AcmeChallenceFolder = @"acme-challenge";
        private const string WellKnownContentType = "text/plain";


        public static IApplicationBuilder UseAcmeChallengeResponder(this IApplicationBuilder app)
        {
            var rootFolderPath = Directory.GetCurrentDirectory();

            var root = new DirectoryInfo(rootFolderPath);
            if (!root.Exists)
                throw new ArgumentException("The provided folder does not exist");

            root.CreateSubdirectory(WellKnownFolder);
            root.CreateSubdirectory(Path.Combine(WellKnownFolder, AcmeChallenceFolder));
            
            app.UseStaticFiles(new StaticFileOptions
            {
                RequestPath = new PathString(WellKnownRequestPath),
                FileProvider = new PhysicalFileProvider(Path.Combine(rootFolderPath, WellKnownFolder)),
                ServeUnknownFileTypes = true,
                DefaultContentType = WellKnownContentType,
            });
            
            return app;
        }
    }

Other Information

I also tried to create /.well-known/ in wwwroot folder, but if the path is not a file, I have the same issue.

Thanks for your help.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
javiercncommented, Apr 8, 2020

Routing in Blazor is very low priority, so you shouldn’t be affected by it. One way to be sure is to plug in your own static files middleware in front of the static files middleware and before app.UseRouting() and that should guarantee that you get to serve whatever file on disk you have.

That’s the reason I asked you to start with an MVC app, so that you can troubleshoot your issue in a simplified environment, given that Blazor is unlikely to affect how that behaves.

0reactions
AlexTeixeiracommented, Apr 8, 2020

Hi @javiercn,

Thanks for the answer. So I should create a basic asp.net core app and then add blazor ? Am I right ?

I used the Blazor Server App template to create my app but I’m not able to serve some extra static folder from wwwroot or using staticFile middleware, is quite dissapointing…

And I can create a new webapp, but if I add blazor after all I should have the same issue because of the routing, no ?

Thanks for your time

Read more comments on GitHub >

github_iconTop Results From Across the Web

Let's encrypt, blazor and Azure Linux Web App
I'm trying to add certificate with let's encrytp to my Blazor Server App that is hosted in a linux azure web app.
Read more >
Containerizing Blazor WASM, ASPNET Core WebApi ...
Guide on containerizing a complex system composed from multiple Blazor WASM apps, ASPNET Core Web Api, NGINX & Let's Encrypt SSL ...
Read more >
Self-Hosted Blazor and Custom Certificates - Microsoft Q&A
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft. 1,060 questions....
Read more >
Hosting a .Net Core App with Nginx and Let's Encrypt
I ran a command on the Ubuntu server to have dotnet generate a new self-signed cert (I believe it was "dotnet dev-certs https")....
Read more >
Help deploying Blazor Server app to Linux
With lets encrypt, half the stuff is done automatically. Third option is to just deploy the compiled blazor project on ports 80/443. Absolutly ......
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