在/usr/local/nginx-1.6.2/conf目录下的nginx.conf文件中进行设置,设置如下内容:
文件头增加:
user root;
为文件服务器的server节点,增加如下内容:
location ~* ^/img/resize/w_(\d+)/h_(\d+)/(.*)$ {
root /usr/local/nginx-1.6.2/html/img/cache;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/img/resize/w_(\d+)/h_(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
set $demins "_$1x$2";
}
set $image_uri /img/resize/$image_path?width=$width&height=$height;
if (!-f $request_filename) {
proxy_pass http://127.0.0.1/$image_uri;
break;
}
proxy_store /usr/local/nginx-1.6.2/html/img/cache/resize$demins/$image_path;
proxy_store_access all:rw;
proxy_set_header Host $host;
expires 1d;
access_log off;
}
location /img/resize/{
alias /usr/local/nginx-1.6.2/html/img/;
image_filter resize $arg_width $arg_height;
image_filter_buffer 50M;
access_log off;
}
访问:
原图
http://hostname/img/image4.jpg
压缩图:
http://hostname/img/resize/w_120/h_129/image4.jpg
图片存储:
/usr/local/nginx-1.6.2/html/img/cache/resize_120x129/image4.jpg
相关推荐
利用nginx对本地文件进行映射,实现可以通过url进行访问,使用场景:例如通过url访问本地图片,而不需要依赖tomcat等容器。
基于openresty+nginx+lua实现文件服务器(包括获取文件及上传文件)
1.查看80端口是否被占用,一般80端口多被apache服务占用。 netstat -anp|grep 80 2.修改apache服务的端口号 ...以上所述是小编给大家介绍的linux服务器上使用nginx访问本地静态资源的方法,希望对大家有所帮助!
Nginx 报 415 调整文件下载大小限制nginx代理nginx时,前端用户请求下载文件, nginx代理会先从后端nginx拿到文件并缓存到本地,然后响应
nginx.conf nginx-1.20.1.tar.gz 这是关于centos8的nginx 和nginx 的配置https文件
Nginx是一个高性能的HTTP和反向代理服务器,也是IMAP/POP3/SMTP代理服务器,是由俄罗斯人lgor Sysoev开发,支持模块加载和卸载,其中upload_...我们要做的工作就是要将这两个模块加入到Nginx中,提供文件上传的服务。
总结了NGINX的相关功能,对比了NGINX与haproxy、LVS、F5等的区别。
nginx文件资源下载
Nginx+upload+lua实现简单文件上传服务
Nginx配置文件 nginx.conf 详解doc文档
nginx配置upstream的资源文件文件,下载下来直接上传至服务解压即可
Nginx 和它的依赖包
nginx容器兼容thinkphp框架配置文件
nginx+fancyindex部署文件服务器(添加上传功能)
nginx配置 nginx配置文件参考 nginx配置文件参考
Nginx核心配置文件Nginx.conf,keepalived核心配置文件keepalived.conf
nginx上传文件大小报错500的解决办法 采用nginx作反向代理,出现了一个诡异的问题,小文件可以提交,大文件会报500内部错误。这个是什么原因导致的呢? 查wiki可知,上传文件大小相关的有三个配置 client_body_...
nginx
Nginx配置文件原始版本,这是刚下来的Nginx服务器最原始的版本内容,下载覆盖即可。
nginx window下的静态文件服务器 location /file/ { alias D:/upload/test/; #换成你的本地磁盘位置 index autoindex on; }