nginx add_header仅生效在最近的一个{}当中。
比如
http { ... add_header X-Xss-Protection "1; mode=block"; add_header X-Frame-Options "SAMEORIGIN"; add_header Content-Security-Policy "default-src https: data: 'unsafe-inline' 'unsafe-eval'"; add_header Strict-Transport-Security "max-age=31536000; includeSubDomains"; add_header X-Content-Type-Options "nosniff"; ... } server { ... server_name www.lvesu.com; add_header X-Xss-Protection "1; mode=block"; add_header X-Frame-Options "SAMEORIGIN"; ... }
则虚拟机www.lvesu.com里,只会有X-Xss-Protection、X-Frame-Options两个head
再比如
server { ... server_name www.lvesu.com; add_header X-Xss-Protection "1; mode=block"; add_header X-Frame-Options "SAMEORIGIN"; if (!-e $request_filename){ ... add_header X-Xss-Protection "1; mode=block"; ... } ... }
如果走到if逻辑里,则只有X-Xss-Protection一个head会生效
最新评论: