如何使用 .htaccess 在 apache 上启用 Expect-Ct

Wil*_*ard 2 apache security .htaccess web

我想在我的网站上启用 Expect-Ct。通过四处搜索,我自己从搜索中创建了代码。

<IfModule mod_headers.c>
Expect-CT: max-age=86400, enforce, report-uri="https://foo.example/report"
</IfModule>
Run Code Online (Sandbox Code Playgroud)

我想问一下这是否正确,什么是report uri?它可以是任何随机链接或其他东西。例如我的网站是 testwebsite.com 那么报告 uri 应该是 testwebsite.com/report ?我如何查看报告?

Mar*_*tin 6

这是一个很好的问题; 虽然注释中提供链接解释了一般语法形式,但它没有解释如何在或 Apache 文件中正确应用此标头。.htaccesshttpd.conf

通过反复试验,我发现这有效:

<IfModule mod_headers.c>
    Header set Expect-CT enforce,max-age=2592000,report-uri="https://foo.example/report"
</IfModule>
Run Code Online (Sandbox Code Playgroud)

请注意,“数据”部分不应有任何空格。

还要注意,由诸如此类的东西检测到的输出redbot.org并不显示完全相同的东西。