Crie ou altere o arquivo .htaccess na raiz do site com o seguinte conteudo:
## Force HTTPS
RewriteEngine On
RewriteCond %{SERVER_PORT} ^80$
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
# Security headers
Header set Strict-Transport-Security "max-age=31536000"
Header set X-Frame-Options "SAMEORIGIN"
Header set X-Content-Type-Options "nosniff"
Header set Upgrade-Insecure-Requests "1"
Header set Referrer-Policy "same-origin"
Header set Permissions-Policy "sync-xhr=(self)"
Header set Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval' https: data: blob:;"
Header set X-XSS-Protection "1; mode=block"
Crie ou altere o arquivo web.config na raiz do site com o seguinte conteúdo:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Force HTTPS" enabled="true">
<match url="(.*)" />
<conditions>
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=31536000" />
<add name="X-Frame-Options" value="SAMEORIGIN" />
<add name="X-Content-Type-Options" value="nosniff" />
<add name="Upgrade-Insecure-Requests" value="1" />
<add name="Referrer-Policy" value="same-origin" />
<add name="Permissions-Policy" value="sync-xhr=(self)" />
<add name="Content-Security-Policy" value="default-src 'self' 'unsafe-inline' 'unsafe-eval' https: data: blob:;" />
<add name="X-XSS-Protection" value="1; mode=block" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
Após aplicar estas configurações, a navegação do seu site será sempre em HTTPS. Os arquivos do seu site, como scripts e imagens, não poderão ser utilizados por terceiros indevidamente.
Acesse securityheaders.com e faça um teste no seu site.