• 흐림동두천 23.5℃
  • 흐림강릉 30.0℃
  • 서울 24.7℃
  • 대전 24.5℃
  • 대구 28.9℃
  • 흐림울산 27.3℃
  • 광주 26.0℃
  • 부산 23.5℃
  • 흐림고창 25.6℃
  • 흐림제주 29.7℃
  • 흐림강화 22.9℃
  • 흐림보은 24.4℃
  • 흐림금산 25.4℃
  • 흐림강진군 26.3℃
  • 흐림경주시 28.5℃
  • 흐림거제 24.1℃
기상청 제공

nginx에서 favicon.ico 관련 404 에러 처리하기

  • 등록 -0001.11.30 00:00:00

Popular sites receive high concurrent web visitor requests and some clients send bad favicon.ico fetch requests. If you are running nginx you probably didn’t notice that, for example: /category/favicon.ico generate significant 404 errors in your server error log file, because this file is located only in root, e.g. /favicon.ico.

Every request for non-existent file takes some load and every 404 missing file error is usually logged into error_log file, unless you have disabled error logging. To forward all non-root favicon.ico requests to /favicon.ico you can set-up the following rewrite rule in nginx.conf file in the correct server{} location:

rewrite ^/(.*)/favicon.ico$ /favicon.ico last;

Voila. Restart the nginx daemon and you will see slightly decreased load on your box.