• 구름많음동두천 17.6℃
  • 맑음강릉 20.3℃
  • 구름많음서울 18.2℃
  • 맑음대전 18.5℃
  • 맑음대구 19.0℃
  • 맑음울산 20.0℃
  • 맑음광주 18.4℃
  • 맑음부산 19.1℃
  • 맑음고창 18.4℃
  • 맑음제주 21.3℃
  • 구름많음강화 15.3℃
  • 구름조금보은 17.3℃
  • 맑음금산 18.1℃
  • 맑음강진군 18.7℃
  • 구름조금경주시 20.7℃
  • 맑음거제 19.7℃
기상청 제공

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.