你好,游客 登录 注册 搜索
背景:
阅读新闻

Nginx 做图片服务器

[日期:2012-12-05] 来源:Linux社区  作者:zlfpasswd [字体:大 中 小]

我们公司领导那个决定啊,公司的图片Windows服务机器 准备迁移到Linux,我勒个去,也不搞个正规的文件系统,先喷下公司 2.8KW 张零碎图片 1.8T 文件占有量,

哥刚刚接手也是被吓了一跳。 Nginx 带动 整个公司核新图片业务,I/0 老高  访问速度龟速,上头给俺的任务就是立马先搞定龟速问题。俺花了一小天的时间搞好所有nginx 配置 速度快了几倍,不多说 贴上配置

events {
      worker_connections  65535;
      use epoll;
          }
 http {
    include      mime.types;
 
    default_type  application/octet-stream;
 
    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;
    access_log  off;
 
    charset utf-8;
 
    keepalive_timeout 60;
 
    sendfile        off;
 
    tcp_nopush    off;
 
    client_header_buffer_size 8k;
 
    large_client_header_buffers 8 128k;
 
    client_max_body_size 300m;
 
    client_body_buffer_size 2048k;
 
    gzip        off;
 
    server {
        server_name _;
 #      rewrite (.*)$ /opt/nginx/html/404.html?;
        return 404;
        error_page 404 = /opt/nginx/html/404.html;
        }
 

    include    nginx-upload.conf;
 
 
 

        server
                {
 
                        listen      80;
                        server_name  file.xxx.com;
                        root /usr/local/wwwweb/file.xxx.com;
 
                        #access_log  /opt/nginx/logs/file.xxx.com;
                        access_log  off;
 
 
 
 
 

        location  ~ .*\.(gif|jpg|jpeg|png)$ {
            root /usr/local/wwwweb/file.xxxx.com;
 
          #if ( !-f request_name  ) {
            if ( $status = 404  ) {
 
                    rewrite /(.*)\.jpg      /$1.JPG;
                      rewrite /(.*)\.JPG      /$1.jpg;
            }
 
        }
 
  }
 }

linux
本文评论   查看全部评论 (2)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
第 2 楼
* 匿名 发表于 2012/12/6 14:09:11
www.ff-bb.** 上面也有不少Nginx方面的配置
第 1 楼
* 匿名 发表于 2012/12/6 14:06:57
location ~ .*\.(gif|jpg|jpeg|png)$ {
root /usr/local/wwwweb/file.xxxx.com;

#if ( !-f request_name ) {
if ( $status = 404 ) {

rewrite /(.*)\.jpg /$1.JPG;
rewrite /(.*)\.JPG /$1.jpg;

这个不错。借鉴一下。