I have set up HSTS on my web application. It is an angular app with a .net backend, hosted on Azure App Services in windows containers. I made changes to the Startup.cs:
services.AddHsts(options =>
{
options.Preload = true;
options.IncludeSubDomains = true;
options.MaxAge = TimeSpan.FromMinutes(5); //.FromDays(60); //.FromSeconds(31536000);
});
services.AddHttpsRedirection(options =>
{
options.RedirectStatusCode = (int)HttpStatusCode.TemporaryRedirect;
options.HttpsPort = 5001;
});
Chrome internals is showing: dynamic_upgrade_mode: FORCE_HTTPS. I cannot figure out how to set up other security headers for an Azure App Service within a Windows container:
- X-XSS-Protection
- X-Frame-Options
- X-Content-Type-Options
- HTTP Strict Transport Security (HSTS)
- Referrer-Policy
- Feature-Policy
- Content-Security-Policy
You can add
Security Headerseither fromProgram.csor inweb.configfile.In
Program.csfile, add the below codeOR
I have taken references from this blog to add security headers in
web.configfile.web.configfile in the Existing Application and add the below setting related to security Headers.You can also refer the SOThread and Blog which explains how to add the Security Headers from
web.configfile.Output: