nginx ngx_http_image_filter_module 简单试用
nginx包含了一个ngx_http_image_filter_module 模块,我们可以方便的进行图片的缩略图,平时一些简单的功能
已经够用了
环境准备
为了简单使用docker-compose 运行,因为openresty 已经默认集成了这个模块,就不用安装了
- docker-compose 文件
version: "3"
services:
nginx:
image: openresty/openresty:alpine-fat
volumes:
- "./nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf"
- "./images/:/opt/img/"
ports:
- "8080:8080"
- nginx conf
主要是加载模块以及配置模块参数,为了简单测试,直接写了固定参数
load_module "modules/ngx_http_image_filter_module.so";
worker_processes 1;
user root;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
lua_code_cache off;
lua_need_request_body on;
gzip on;
resolver 127.0.0.11 ipv6=off;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
gzip_min_length 2k;
gzip_buffers 4 16k;
gzip_comp_level 4;
gzip_types text/plain text/css image/png application/javascript image/jpeg image/gif;
server {
listen 8080;
server_name app;
charset utf-8;
default_type text/html;
location / {
default_type text/plain;
index index.html index.htm;
}
location = /favicon.ico {
root /opt/app/static;
}
location /img/ {
root /opt;
image_filter resize 600 400;
error_page 415 = /empty;
image_filter_jpeg_quality 95;
image_filter_buffer 20M;
}
location = /empty {
empty_gif;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
测试
为了简单,使用数据卷挂载了一个简单的图片目录
- 启动
docker-compose up -d
- 效果
http://localhost:8080/img/index.png
原图信息 
缩略图信息 
说明
测试使用了很简单的配置,实际上我们可以用这个做好多强大的功能,类似的可以集成thumbor 实现更强大的功能
参考资料
https://www.cnblogs.com/rongfengliang/p/8650784.html
https://github.com/rongfengliang/openresty-image-filter-demo
https://nginx.org/en/docs/http/ngx_http_image_filter_module.html
https://github.com/rongfengliang/mino-thumbor-openresty
nginx ngx_http_image_filter_module 简单试用的更多相关文章
- nginx知识点简单回顾
html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...
- Centos6.7配置Nginx+Tomcat简单整合
系统环境:Centos 6.7 软件环境:JDK-1.8.0_65.Nginx-1.10.3.Tomcat-8.5.8 文档环境:/opt/app/ 存放软件目录,至于mkdir创建文件就不用再说了 ...
- nginx+keepalived简单双机主从热备
双机主从热备概述 可以两台机子互为热备,平时各自负责各自的服务.在做上线更新的时候,关闭一台服务器的tomcat后,nginx自动把流量切换到另外一台服务的后备机子上,从而实现无痛更新,保持服务的持续 ...
- Linux yum的配置 , python环境管理, nginx搭建简单学习
Linux yum的配置 , python环境管理, nginx搭建简单学习 一丶配置yum的数据仓库 ### yum 工具, 方便,自行解决软件之间的依赖关系. # 配置yum源仓库 (可以使用,清 ...
- 以实际的WebGIS例子探讨Nginx的简单配置
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 以实际项目中的一个例子来详细讲解Nginx中的一般配置,其中涉 ...
- nginx 配置管理 - 简单也复杂
由于涉及到h5与后端交互,跨域问题,所以公司的开放测试服务器让我们自己搞nginx.顺便提升一下nginx的实践. nginx的安装,没什么难度了,百度一堆,如果源码安装就一步步来吧.(最简单的方式: ...
- Nginx个人简单理解
首先我们来补充下一些基本知识: 什么是代理服务器? 先举个简单的例子,现在我们在百度访问谷歌的网站,发现现在进不去,这个时候我们可以FQ(关于FQ,可以借鉴下这个博文:http://zhangge.n ...
- jQuery无刷新上传之uploadify简单试用
先简单的侃两句:貌似已经有两个月的时间没有写过文章了,不过仍会像以前那样每天至少有一至两个小时是泡在园子里看各位大神的文章.前些天在研究“ajax无刷新上传”方面的一些插件,用SWFUpload实现了 ...
- Linux下Nginx+PHP 简单安装配置
测试环境 Linux 2.6.18nginx-1.0.4 http://www.nginx.org/php-5.3.6 http://www.php.net/ 一,安装Nginxwget http:/ ...
随机推荐
- Python的布尔值与空值
1.Boolean值(布尔值) 一个布尔值只有Ture.False两种值 b1 =True b2 =False print (b1,b2)>>>True False 2.空值(non ...
- plt库
- 解决sublime text 3使用Install Package时出现There are no packages available for installation问题
package control一直弹出There are no packages available for installation,由于国内环境屏蔽了https://packagecontrol. ...
- 推理机Jess,Racer,Jena
推理机 Jess(Java Expert Shell System)是基于Java语言的CLISP推理机. CLISP是基于产生式的前向推理引擎,许多上层的推理任务,都要映射到这个推理引擎上来运行. ...
- Linux:Linux Mint系统的安装
今天就更新一篇了,其实Linux系统大部分都是用虚拟机来安装的,毕竟Windows系统才是我们常用的系统,而Linux系统只是我们工作时才用的,而且使用虚拟机是非常方便的,不用重启电脑就可以使用另一种 ...
- python调用c++ DLL
python DLL = ctypes.cdll.LoadLibrary("./dll_file.so") #引入dllDLL.func(mat.ctypes.data // (1 ...
- 北大poj- 1012
Joseph Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 56348 Accepted: 21526 Descript ...
- Python_随机序列生成_白噪声
本文介绍如何利用Python自行生成随机序列,实现了 Whichmann / Hill 生成器. 参考: [1]Random Number Generation and Monte Carlo Met ...
- mybatis 源码分析二
1.SqlSession下的四大对象 Executor.StatementHandler.ParameterHandler.ResultSetHandler StatementHandler的作用是使 ...
- govendor 无法添加.h文件
例如:github.com\ethereum\go-ethereum\crypto\secp256k1 是一个CGO项目 通过govendor add +external只能引入secp256k1下的 ...