我们在使用Nginx搭建HTTP的web server的过程中,一般都很顺利,默认的网站根目录一般是/usr/local/nginx/html,我们也可以正常访问到Nginx的欢迎信息,比如使用下面的网址:

http://localhost/

但是发现运行一段时间后,Nginx的error日志中会定期抱怨说,没有找到favicon.ico文件?

发生这种错误的原因一般是Nginx在根目录上找不到这个文件。我们可以在网上下载一个ico文件放在根目录下面就可以了。但是现在的业务场景有些区别:

我使用Nginx作为前台服务器,在80端口接收所有的http请求,对本地能缓存的资源直接提供服务,否则转发到upstream上的其他服务器处理,比如转给fastDFS,或者是ATS等等,下面的nginx.conf是一个例子:

user  www www;
worker_processes  4;error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;pid        logs/nginx.pid;
worker_rlimit_nofile 65535;
google_perftools_profiles /tmp/tcmalloc;events {worker_connections  65535;
}http {include       mime.types;default_type  application/octet-stream;server_tokens off;log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';#access_log  logs/access.log  main;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 50m;sendfile        on;tcp_nopush      on;tcp_nodelay     on;#keepalive_timeout  0;keepalive_timeout  60;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 256k;fastcgi_intercept_errors on;gzip  on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.0;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on;upstream ats {server 127.0.0.1:8081;}server {listen       80;server_name  localhost;#charset koi8-r;#access_log  logs/host.access.log  main;location / {root   html;index  index.html index.htm;proxy_pass http://ats$request_uri;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;expires 2h;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   html;}location /test-js {root html;try_files $uri /;expires 10d;}location /test-img {root html;try_files $uri /;expires 10d;}location /test-html {root html;try_files $uri /;expires 10d;}# just use for taoyx testlocation /taoyx-test {root html;}# just for tulu testlocation /tulu {root html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#location ~ \.php$ {root           html;fastcgi_pass   127.0.0.1:9000;fastcgi_index  index.php;fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;include        fastcgi_params;}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}}# another virtual host using mix of IP-, name-, and port-based configuration##server {#    listen       8000;#    listen       somename:8080;#    server_name  somename  alias  another.alias;#    location / {#        root   html;#        index  index.html index.htm;#    }#}# HTTPS server##server {#    listen       443;#    server_name  localhost;#    ssl                  on;#    ssl_certificate      cert.pem;#    ssl_certificate_key  cert.key;#    ssl_session_timeout  5m;#    ssl_protocols  SSLv2 SSLv3 TLSv1;#    ssl_ciphers  HIGH:!aNULL:!MD5;#    ssl_prefer_server_ciphers   on;#    location / {#        root   html;#        index  index.html index.htm;#    }#}}

我现在在根目录下存放一个ico文件,如何让Nginx直接去本地拿这个文件,而不转发给其他服务器呢?直接在nginx.conf中增加下面一行就可以了:

        # set site faviconlocation /favicon.ico {root html;}

下面按照我的配置,访问Nginx的欢迎页面就可以正常看到ico图标了:

不能忽略的Nginx做web服务器的favicon.ico图像找不到问题相关推荐

  1. 试验thrift做后端rpc,nginx做web服务器, python后端php前端

    因为后端的服务很负责,训练的模型都是基于python的tensorflow的,所以用RPC(remote procedual comminication): 接口用的是php写的,方便http协议调用 ...

  2. Nginx做web服务器linux内核参数优化

    关于Linux内核参数的优化:net.ipv4.tcp_max_tw_buckets = 6000timewait的数量,默认是180000.net.ipv4.ip_local_port_range ...

  3. nginx高性能WEB服务器系列之七--nginx反向代理

    nginx系列友情链接: nginx高性能WEB服务器系列之一简介及安装 https://www.cnblogs.com/maxtgood/p/9597596.html nginx高性能WEB服务器系 ...

  4. keepalived架设简单高可用的nginx的web服务器   ----那些你不知道的秘密

    keepalived架设简单高可用的nginx的web服务器----那些你不知道的秘密 如果負載均衡軟件不使用LVS的話,那麼keepalived的配置是相當的簡單的,只需要配置好MASTER和SLA ...

  5. Nginx作为web服务器的安装配置

    Nginx作为web服务器的安装配置 (关注官方网站http://nginx.org/)   Nginx简介 是一个高性能的 HTTP 和 反向代理服务器,由俄罗斯的程序设计师Igor Sysoev所 ...

  6. Nginx + PHP Web服务器

    前言:本文是我撰写的关于搭建"Nginx + PHP(FastCGI)"Web服务器的第6篇文章.本系列文章作为国内最早详细介绍 Nginx + PHP 安装.配置.使用的资料之一 ...

  7. delphi怎么获得文件服务器,delphi做web服务器

    delphi做web服务器 内容精选 换一换 公网域名解析是基于Internet网络的域名解析过程,可以把人们常用的域名(如www.example.com)转换成用于计算机连接的IP地址(如1.2.3 ...

  8. Linux - nginx 搭建 Web服务器

    前言 在之前,已经对 nginx 有过基本的介绍. 现在尝试利用 nginx 来 搭建一个 web服务器. 正文 1.什么是 Web 服务器? Web服务器也称为WWW (WORLD WIDE WEB ...

  9. Fikker 站长缓存无法缓存用 IIS 做 Web 服务器的 PHP 页面的解决方法

    2019独角兽企业重金招聘Python工程师标准>>> 在用户使用 Fikker 站长缓存和搭建CDN过程中发现用 IIS 做 Web 服务器的 PHP 页面不能缓存,主要原因是 H ...

最新文章

  1. Python 3.8 新特性全面解读
  2. 解决哈希(HASH)冲突的主要方法
  3. php中储存数据类型,PHP中的数据类型
  4. 『原创』网站测试计划模板
  5. 明日之后抄袭rust_古人怎么抄袭?何法盛偷窃原著,宋之问压杀外甥,班固参考史记...
  6. 从傅里叶(Fourier)变换到伽柏(Gabor)变换再到小波(Wavelet)变换
  7. Android 利用jsoup解析 html
  8. sharepoint2010无法创建网站集
  9. Java:集合,Array、Collection(List/Set/Queue)、Map的遍历,比如:ArrayList,LinkedList,HashSet,HashMap...
  10. (转)技嘉 MA790FXT-UD5P搭配AMD X4 965超频解析
  11. C++之学生成绩管理系统
  12. ts540服务器安装系统,ThinkServer TS540 OS安装手册 V1.3.pdf
  13. 关于移动端H5获取微信非静默授权被拦截进入【微信快照页】问题及解决方案
  14. c语言easyx背景图片,C++之设置背景图片(Easyx)
  15. JSON.stringify(value, replacer, space)详解
  16. HOJ 1276 士兵队列训练问题(stl, 水题)
  17. 2021年中国家具制造业经营现状分析:营业收入达8004.6亿元,利润总额达433.7亿元[图]
  18. 关于机器翻译,看这一篇就够了
  19. 【评测】无血清细胞冻存液
  20. Helen Of Troy 海伦特洛伊(新木马屠城记)

热门文章

  1. php防止网站被镜像,网站被等恶意镜像的解决、反制措施详细教程
  2. 白话学习MVC(六)模型绑定
  3. Delphi 之Copyrect的使用
  4. .Net MVC3中取得当前区域的名字(Area name)
  5. Enterprise Architect 7 入门教程 1
  6. 软件设计之 数据库设计
  7. html5网页怎么实现内容追加,纯js实现网页内容复制后自动追加自定义内容
  8. java 泛型 父子,Java泛型-mb601cf8a78cc07的博客-51CTO博客
  9. leetcode 解压缩_谁说 Python 的 shutil 不支持 7z 解压缩,我来教你扩展它的功能!...
  10. tcp udp区别优缺点_CCNA必懂篇,传输层协议TCP/UDP的区别和作用