- 核心模块
- ngx_core
- ngx_errlog
- ngx_conf
- ngx_events
- ngx_event_core
- ngx_epll
- ngx_regex
- 可选 HTTP 模块
- ngx_http_addition #在响应请求的页面开始或者结尾添加文本信息
- ngx_http_degradation #在低内存的情况下允许服务器返回 444 或者 204 错误
- ngx_http_perl
- ngx_http_flv #支持将 Flash 多媒体信息按照流文件传输,可以根据客户端指定的开始位置返回 Flash
- ngx_http_geoip #支持解析基于 GeoIP 数据库的客户端请求
- ngx_google_perftools
- ngx_http_gzip #gzip 压缩请求的响应
- ngx_http_gzip_static #搜索并使用预压缩的以.gz 为后缀的文件代替一般文件响应客户端请求
- ngx_http_image_filter #支持改变 png,jpeg,gif 图片的尺寸和旋转方向
- ngx_http_mp4 #支持.mp4,.m4v,.m4a 等多媒体信息按照流文件传输,常与 ngx_http_flv 一起使用
- ngx_http_random_index #当收到 / 结尾的请求时,在指定目录下随机选择一个文件作为 index
- ngx_http_secure_link #支持对请求链接的有效性检查
- ngx_http_ssl #支持 https
- ngx_http_stub_status
- ngx_http_sub_module #使用指定的字符串替换响应中的信息
- ngx_http_dav #支持 HTTP 和 WebDAV 协议中的 PUT/DELETE/MKCOL/COPY/MOVE 方法
- ngx_http_xslt #将 XML 响应信息使用 XSLT 进行转换
- 邮件服务模块
- ngx_mail_core
- ngx_mail_pop3
- ngx_mail_imap
- ngx_mail_smtp
- ngx_mail_auth_http
- ngx_mail_proxy
- ngx_mail_ssl
- 第三方模块
Syntas: stub_status;Default:—Context:server,location
http_random_index_module
目录中选择一个随机主页
语法:random_index on|off默认:random_index off;Context:location
secure_link_module模块
- 制定并允许检查请求的链接的真实性以及保护资源免遭未经授权的访问。
- 限制链接生效周期
syntax: secure_link expressiondefault:-context:server, location,server复制代码
图示syntax: secure_link_md5 expressiondefault:-context:server, location,http复制代码


http_geoip_module使用场景
基于ip地址匹配MaxMind GeoIp 二进制文件,读取ip所在地域信息
yum install nginx-module-geoip复制代码
- 区别国内外做http访问规则
- 区别国内城市地域做http访问规则
dockerfile 编译
# nginx Dockerfile# Version 1.0# author fendo# Base images 基础镜像FROM centos:centos7#FROM hub.c.163.com/netease_comb/centos:7#安装相关依赖RUN yum -y updateRUN yum -y install gcc gcc-c++ autoconf automake makeRUN yum -y install zlib zlib-devel openssl* pcre* wget lua-devel#MAINTAINER 维护者信息MAINTAINER fendo aa@qq.com#ADD 获取url中的文件,放在当前目录下ADD http://nginx.org/download/nginx-1.14.0.tar.gz /tmp/#LuaJIT 2.1#ADD http://luajit.org/download/LuaJIT-2.0.5.tar.gz /tmp/ADD https://github.com/LuaJIT/LuaJIT/archive/v2.0.5.tar.gz /tmp/#ngx_devel_kit(NDK)模块ADD https://github.com/simpl/ngx_devel_kit/archive/v0.3.0.tar.gz /tmp/#lua-nginx-module 模块ADD https://github.com/openresty/lua-nginx-module/archive/v0.10.13.tar.gz /tmp/#nginx ngx_cache_purge模块ADD http://labs.frickle.com/files/ngx_cache_purge-2.3.tar.gz /tmp/#切换目录WORKDIR /tmp#安装LuaJIT 2.0.5#RUN wget http://luajit.org/download/LuaJIT-2.0.5.tar.gz -P /tmp/RUN tar zxf v2.0.5.tar.gzWORKDIR /tmp/LuaJIT-2.0.5#RUN cd LuaJIT-2.0.5RUN make PREFIX=/usr/local/luajitRUN make install PREFIX=/usr/local/luajit#安装ngx_devel_kit(NDK)WORKDIR /tmpRUN tar -xzvf v0.3.0.tar.gzRUN cp -r ngx_devel_kit-0.3.0/ /usr/local/src/#安装lua-nginx-module模块RUN tar -xzvf v0.10.13.tar.gzRUN cp -r lua-nginx-module-0.10.13/ /usr/local/src/#安装nginx ngx_cache_purge模块RUN tar -xzvf ngx_cache_purge-2.3.tar.gzRUN cp -r ngx_cache_purge-2.3/ /usr/local/src/#设置环境变量RUN export LUAJIT_LIB=/usr/local/libRUN export LUAJIT_INC=/usr/local/include/luajit-2.0RUN mkdir -p {/usr/local/nginx/logs,/var/lock}#编译安装NginxRUN useradd -M -s /sbin/nologin nginxRUN tar -zxvf nginx-1.14.0.tar.gzRUN mkdir -p /usr/local/nginxRUN cd /tmp/nginx-1.14.0 \&& ./configure --prefix=/etc/nginx --user=nginx --group=nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/var/run/nginx.pid \--lock-path=/var/run/nginx.lock \--with-ld-opt="-Wl,-rpath,/usr/local/luajit/lib" \--with-http_stub_status_module \--with-http_ssl_module \--with-http_sub_module \--add-module=/usr/local/src/lua-nginx-module-0.10.13 \--add-module=/usr/local/src/ngx_devel_kit-0.3.0 \--add-module=/usr/local/src/ngx_cache_purge-2.3 \&& make && make install#参数说明#--prefix 用于指定nginx编译后的安装目录#--add-module 为添加的第三方模块,此次添加了fdfs的nginx模块#--with..._module 表示启用的nginx模块,如此处启用了http_ssl_module模块RUN /etc/nginx/sbin/nginx -c /etc/nginx/nginx.confRUN ln -s /usr/local/nginx/sbin/* /usr/local/sbin/#EXPOSE 映射端口EXPOSE 80 443#CMD 运行以下命令#CMD ["nginx"]CMD ["/etc/nginx/sbin/nginx","-g","daemon off;"]
参考
https://gist.github.com/hermanbanken/96f0ff298c162a522ddbba44cad31081
