LoginSignup
22
18

More than 5 years have passed since last update.

Nginxで適当なfaviconを設定する

Posted at

faviconがどうでもいいサービスなのにfavicon.icoにアクセスされるのは気持ちのいいものではないです。
というわけで以下の様な設定をしていました。

location = /favicon.ico {
  access_log off;
  return 200;
}

まあこれでも困ることってないと思うのですが、以下の様な需要があるかもしれません。

  • 一応適当な画像を返したい
  • キャッシュして欲しい

そういう場合は以下の様な設定が良さそうです。


location = /favicon.ico {
  access_log off;
  empty_gif;
  expires 30d;
}

empty_gifで1px四方の透明なGIF画像を返してくれるらしいです。便利。

22
18
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
22
18