【问题标题】:Nginx config is not case insensitive to image filesNginx 配置对图像文件不区分大小写
【发布时间】:2014-04-15 02:12:42
【问题描述】:

图片只有在大小写正确时才会显示。这些需要不区分大小写,请参阅我的配置文件。

我遇到问题的图片位于:

http://domain.com/sites/default/files/vimages/imagename.jpg

但不是在

http://domain.com/sites/default/files/vimages/imagename.JPG

服务器{

   listen 80;

   server_name domain.com;
   root /home/domain.com/www; ## <-- Your only path reference.

   access_log /home/domain.com/logs/access.log;
   error_log /home/domain.com/logs/error.log;

   # Enable compression, this will help if you have for instance advagg‎ module
   # by serving Gzip versions of the files.
   gzip_static on;

   gzip on;

   location = /favicon.ico {
           log_not_found off;
           access_log off;
   }

   location = /robots.txt {
           allow all;
           log_not_found off;
           access_log off;
   }

   # This matters if you use drush
   location = /backup {
           deny all;
   }

   # Very rarely should these ever be accessed outside of your lan
   location ~* \.(txt|log)$ {
           allow 192.168.0.0/16;
           deny all;
   }
   location ~ \..*/.*\.php$ {
           return 403;
   }

   # No no for private
   location ~ ^/sites/.*/private/ {
           return 403;
   }

   # Block access to "hidden" files and directories whose names begin with a
   # period. This includes directories used by version control systems such
   # as Subversion or Git to store control files.
   location ~ (^|/)\. {
           return 403;
   }

   location / {
           # This is cool because no php is touched for static content
           try_files $uri @rewrite;
   }

   location @rewrite {
           # Some modules enforce no slash (/) at the end of the URL
           # Else this rewrite block wouldn't be needed (GlobalRedirect)
           rewrite ^ /index.php;
   }

   location ~ \.php$ {
           try_files $uri =404;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           #fastcgi_pass 127.0.0.1:9000;
           fastcgi_read_timeout 180;
           fastcgi_intercept_errors on;
           fastcgi_pass unix:/var/run/php5-fpm.sock;
           fastcgi_index index.php;
           include fastcgi_params;
   }

   location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
           expires 52w;
           add_header  Cache-Control "max-age=31449600, no-transform, public";
           log_not_found off;
   }

   # Catch image styles for D7 too.
   location ~* ^/sites/.*/files/styles/ {
           try_files $uri @rewrite;
   }
   location ~* /sites/.*/files/vimages/ {
           try_files $uri @rewrite;
   }
   # Fighting with ImageCache? This little gem is amazing.
   location ~ ^/sites/.*/files/imagecache/ {
           try_files $uri @rewrite;
   }

}

【问题讨论】:

  • 为什么要这样?大多数 unix 文件系统都区分大小写

标签: nginx drupal-7 case-insensitive


【解决方案1】:

Nginx 正在针对文件系统工作,并且在从目录提供服务时无法控制文件的名称。

如果您想要不区分大小写,则需要进行重写。

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-28
  • 2012-02-03
  • 1970-01-01
  • 2016-11-05
  • 2014-03-09
相关资源
最近更新 更多