LoginSignup
184
186

More than 5 years have passed since last update.

Webサーバで指定すべきヘッダ

Last updated at Posted at 2012-12-26

セキュリティ対策などでWebサーバ側で指定した方が良いヘッダー。
ありそうでまとめられてなかったので投稿しておきます。

2016-02-05 update
まだストックされる方がたまにいるようなので、簡単に更新しました。

XSS対策

  • nginx
add_header X-XSS-Protection "1; mode=block";
  • Apache
Header set X-XSS-Protection "1; mode=block"

クリックジャッキング

例ではDENYにしているが、他にSAMEORIGIN、ALLOW-FROMなど

  • nginx
add_header X-Frame-Options DENY;
  • Apache
Header set X-Frame-Options DENY

X-Frame-Options レスポンスヘッダ - HTTP | MDN

IEで発生するコンテンツタイプSniffing対策

  • nginx
add_header X-Content-Type-Options nosniff;
  • Apache
Header set X-Content-Type-Options nosniff

Content-Security-Policy

CSP (Content Security Policy) - Security | MDN
弊社のホームページにContent Security Policy(CSP)を導入しました | HASHコンサルティングオフィシャルブログ

以下https採用時

Public Key Pining

SSL証明書などからbase64に変換後。オプションがいくつかあるので、サイトにあった形で。

  • nginx
add_header Public-Key-Pins "pin-sha256='base64==xxxxxxxxxxxxxxxxxxxxxx='; max-age=5184000";

Public Key Pinning - Web security | MDN

Strict-Transport-Security

  • nginx
add_header Strict-Transport-Security max-age=15768000;

HTTP Strict Transport Security - Security | MDN

184
186
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
184
186