How to configure UmbracoCMS on Linux with https?
d
Hey at the moment I use the caddy web server as reverse proxy in front of the dotnet core umbraco application. Now I saw that images and other files get loaded over http. Can someone tell me how do I have to confiure umbraco to solve this problem? My website is https://danobe.dev and when you look at the canonical url it uses http:// instead of https. I use the SEO Toolkit and thought it is regarding to this plugin the problem. But now I figured it's because my dotnet core application runs on http. Has someone any hints on how to solve this issue? Kind regards, Daniel
c
What code are you using to generate the canonical?
d
I use SEO Toolkit which autogenerates it. tag is used ... I testet also on the images the following @Model.KindOfEquipmentPhoto.Url(mode:UrlMode.Absolute) which gives me a http:// address ... so the whole application must run in http context but caddy offers https ...
r
While I haven't tested it with Umbraco it should be possible to use the Forwarded Header Middleware (see. https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-7.0) to override the protocol using the
X-Forwarded-Proto
header, which IIRC Caddy sets by default. Just make sure it's registered before any Umbraco middleware.
c
You could always do what I've done a few times which is:
Copy code
<link rel="canonical" href="https://danobe.dev@(Model.Url())">
It's a bit of a cheat but it works šŸ™‚
d
yeah but i've also open graph image tags wich run also at http:// at the moment, so its no fix for me ... i've implemented now the fix from @rasmusjp but haven't deployed it yet because I have to do a few fixes before deploying .. I let you people know if it worked! šŸ™‚
@rasmusjp I deployed my site today and had to grind a little bit. Turns out this line solves the problem:
Copy code
csharp
app.Use((context, next) =>
{
    context.Request.Scheme = "https";
    return next(context);
});
Thank you for your help! šŸ™‚
r
Awesome, I’m glad you got it working šŸ˜€