<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Cloudflare on Blog式日记小站</title><link>http://localhost:1313/categories/cloudflare/</link><description>Recent content from Blog式日记小站</description><generator>Hugo</generator><language>en</language><managingEditor>bi499096@hotmail.com (溟里)</managingEditor><webMaster>bi499096@hotmail.com (溟里)</webMaster><copyright>All articles on this blog are licensed under the BY-NC-SA license agreement unless otherwise stated. Please indicate the source when reprinting!</copyright><lastBuildDate>Sat, 05 Sep 2026 13:43:05 +0800</lastBuildDate><atom:link href="http://localhost:1313/categories/cloudflare/index.xml" rel="self" type="application/rss+xml"/><item><title>Nginx响应头优化问题记录</title><link>http://localhost:1313/posts/nginx%E5%93%8D%E5%BA%94%E5%A4%B4%E4%BC%98%E5%8C%96%E9%97%AE%E9%A2%98%E8%AE%B0%E5%BD%95/</link><pubDate>Sat, 05 Sep 2026 13:43:05 +0800</pubDate><author>bi499096@hotmail.com (溟里)</author><guid>http://localhost:1313/posts/nginx%E5%93%8D%E5%BA%94%E5%A4%B4%E4%BC%98%E5%8C%96%E9%97%AE%E9%A2%98%E8%AE%B0%E5%BD%95/</guid><description>
<![CDATA[<h1>Nginx响应头优化问题记录</h1><p>Author: 溟里(bi499096@hotmail.com)</p>
        
          <h2 id="一原始问题">
<a class="header-anchor" href="#%e4%b8%80%e5%8e%9f%e5%a7%8b%e9%97%ae%e9%a2%98"></a>
一、原始问题
</h2><p>查看FeHelper在 Nginx 配置中发现三个关键头部缺失：</p>
<p>❌ Cache-Control —— 浏览器端无缓存策略</p>
<p>❌ X-Content-Type-Options —— 存在 MIME 嗅探 XSS 风险</p>
<p>❌ X-Frame-Options —— 可能被嵌入 iframe 遭受点击劫持</p>
<h2 id="二已完成的优化-成功">
<a class="header-anchor" href="#%e4%ba%8c%e5%b7%b2%e5%ae%8c%e6%88%90%e7%9a%84%e4%bc%98%e5%8c%96-%e6%88%90%e5%8a%9f"></a>
二、已完成的优化（✅ 成功）
</h2><h3 id="nginx-配置添加">
<a class="header-anchor" href="#nginx-%e9%85%8d%e7%bd%ae%e6%b7%bb%e5%8a%a0"></a>
Nginx 配置添加
</h3><ul>
<li>静态资源（css/js/图片等）缓存 30 天，添加 <code>Cache-Control: public, no-transform</code></li>
<li>HTML 页面添加 <code>Cache-Control: no-cache, must-revalidate</code></li>
<li>安全头部已在 Nginx 中配置</li>
</ul>
<h3 id="配置验证">
<a class="header-anchor" href="#%e9%85%8d%e7%bd%ae%e9%aa%8c%e8%af%81"></a>
配置验证
</h3><div class="highlight"><pre tabindex="0" style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>curl -I http://localhost/
</span></span></code></pre></div><p>确认 Nginx 本地响应完全正常，缓存策略已生效 ✅</p>
<h2 id="三当前状态-部分受限">
<a class="header-anchor" href="#%e4%b8%89%e5%bd%93%e5%89%8d%e7%8a%b6%e6%80%81-%e9%83%a8%e5%88%86%e5%8f%97%e9%99%90"></a>
三、当前状态（⚠️ 部分受限）
</h2><table>
	<thead>
			<tr>
					<th>配置项</th>
					<th>Nginx 本地</th>
					<th>公网访问 (Cloudflare Tunnel)</th>
			</tr>
	</thead>
	<tbody>
			<tr>
					<td>Cache-Control</td>
					<td>✅ 生效</td>
					<td>✅ 生效</td>
			</tr>
			<tr>
					<td>X-Content-Type-Options</td>
					<td>✅ 生效</td>
					<td>❌ 被过滤</td>
			</tr>
			<tr>
					<td>X-Frame-Options</td>
					<td>✅ 生效</td>
					<td>❌ 被过滤</td>
			</tr>
			<tr>
					<td>X-XSS-Protection</td>
					<td>✅ 生效</td>
					<td>❌ 被过滤</td>
			</tr>
	</tbody>
</table>
<blockquote>
<p>通过 cloudflared 免费 Tunnel 访问时，Cloudflare 会剥离自定义响应头。这是免费域名的限制。</p>
</blockquote>
        
        <hr><p>Published on 2026-09-05 at <a href='http://localhost:1313/'>Blog式日记小站</a>, last modified on 2026-09-05</p>]]></description><category>cloudflare</category><category>工具运用</category><category>Nginx</category></item></channel></rss>