本文参考配置https://github.com/Parli/nginx-vts-docker 稍作修改

搜索到的docker镜像nginx版本比较低,为1.11,1.13,这里用的nginx版本为1.20.0

Dockerfile

FROM alpine:3.5LABEL maintainer="eric@slant.co"ENV NGINX_VERSION 1.22.0
ENV VTS_VERSION 0.2.1RUN GPG_KEYS=B0F4253373F8F6F510D42178520A9993A1C052F8 \&& CONFIG="\--prefix=/etc/nginx \--sbin-path=/usr/sbin/nginx \--modules-path=/usr/lib/nginx/modules \--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 \--http-client-body-temp-path=/var/cache/nginx/client_temp \--http-proxy-temp-path=/var/cache/nginx/proxy_temp \--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \--http-scgi-temp-path=/var/cache/nginx/scgi_temp \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module \--with-http_xslt_module=dynamic \--with-http_image_filter_module=dynamic \--with-http_geoip_module=dynamic \--with-http_perl_module=dynamic \--with-threads \--with-stream \--with-stream_ssl_module \--with-stream_ssl_preread_module \--with-stream_realip_module \--with-stream_geoip_module=dynamic \--with-http_slice_module \--with-mail \--with-mail_ssl_module \--with-compat \--with-file-aio \--with-http_v2_module \--add-module=/usr/src/nginx-module-vts-$VTS_VERSION \" \&& addgroup -S nginx \&& adduser -D -S -h /var/cache/nginx -s /sbin/nologin -G nginx nginx \&& apk add --no-cache --virtual .build-deps \gcc \libc-dev \make \openssl-dev \pcre-dev \zlib-dev \linux-headers \curl \gnupg \libxslt-dev \gd-dev \geoip-dev \perl-dev \&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz -o nginx.tar.gz \&& curl -fSL http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz.asc  -o nginx.tar.gz.asc \&& curl -fSL https://github.com/vozlt/nginx-module-vts/archive/v$VTS_VERSION.tar.gz  -o nginx-modules-vts.tar.gz \&& export GNUPGHOME="$(mktemp -d)" \&& found=''; \for server in \ha.pool.sks-keyservers.net \hkp://keyserver.ubuntu.com:80 \hkp://p80.pool.sks-keyservers.net:80 \pgp.mit.edu \; do \echo "Fetching GPG key $GPG_KEYS from $server"; \gpg --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$GPG_KEYS" && found=yes && break; \done; \test -z "$found" && echo >&2 "error: failed to fetch GPG key $GPG_KEYS" && exit 1; \gpg --batch --verify nginx.tar.gz.asc nginx.tar.gz \&& rm -r "$GNUPGHOME" nginx.tar.gz.asc \&& mkdir -p /usr/src \&& tar -zxC /usr/src -f nginx.tar.gz \&& tar -zxC /usr/src -f nginx-modules-vts.tar.gz \&& rm nginx.tar.gz nginx-modules-vts.tar.gz \&& cd /usr/src/nginx-$NGINX_VERSION \&& ./configure $CONFIG --with-debug \&& make -j$(getconf _NPROCESSORS_ONLN) \&& mv objs/nginx objs/nginx-debug \&& mv objs/ngx_http_xslt_filter_module.so objs/ngx_http_xslt_filter_module-debug.so \&& mv objs/ngx_http_image_filter_module.so objs/ngx_http_image_filter_module-debug.so \&& mv objs/ngx_http_geoip_module.so objs/ngx_http_geoip_module-debug.so \&& mv objs/ngx_http_perl_module.so objs/ngx_http_perl_module-debug.so \&& mv objs/ngx_stream_geoip_module.so objs/ngx_stream_geoip_module-debug.so \&& ./configure $CONFIG \&& make -j$(getconf _NPROCESSORS_ONLN) \&& make install \&& rm -rf /etc/nginx/html/ \&& mkdir /etc/nginx/conf.d/ \&& mkdir -p /usr/share/nginx/html/ \&& install -m644 html/index.html /usr/share/nginx/html/ \&& install -m644 html/50x.html /usr/share/nginx/html/ \&& install -m755 objs/nginx-debug /usr/sbin/nginx-debug \&& install -m755 objs/ngx_http_xslt_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_xslt_filter_module-debug.so \&& install -m755 objs/ngx_http_image_filter_module-debug.so /usr/lib/nginx/modules/ngx_http_image_filter_module-debug.so \&& install -m755 objs/ngx_http_geoip_module-debug.so /usr/lib/nginx/modules/ngx_http_geoip_module-debug.so \&& install -m755 objs/ngx_http_perl_module-debug.so /usr/lib/nginx/modules/ngx_http_perl_module-debug.so \&& install -m755 objs/ngx_stream_geoip_module-debug.so /usr/lib/nginx/modules/ngx_stream_geoip_module-debug.so \&& ln -s ../../usr/lib/nginx/modules /etc/nginx/modules \&& strip /usr/sbin/nginx* \&& strip /usr/lib/nginx/modules/*.so \&& rm -rf /usr/src/nginx-$NGINX_VERSION \\# Bring in gettext so we can get `envsubst`, then throw# the rest away. To do this, we need to install `gettext`# then move `envsubst` out of the way so `gettext` can# be deleted completely, then move `envsubst` back.&& apk add --no-cache --virtual .gettext gettext \&& mv /usr/bin/envsubst /tmp/ \\&& runDeps="$( \scanelf --needed --nobanner /usr/sbin/nginx /usr/lib/nginx/modules/*.so /tmp/envsubst \| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \| sort -u \| xargs -r apk info --installed \| sort -u \)" \&& apk add --no-cache --virtual .nginx-rundeps $runDeps \&& apk del .build-deps \&& apk del .gettext \&& mv /tmp/envsubst /usr/local/bin/ \\# forward request and error logs to docker log collector&& ln -sf /dev/stdout /var/log/nginx/access.log \&& ln -sf /dev/stderr /var/log/nginx/error.logCOPY nginx.conf /etc/nginx/nginx.conf
COPY default.conf /etc/nginx/conf.d/default.confEXPOSE 80 443STOPSIGNAL SIGTERMCMD "nginx"

nginx.conf

daemon off;
user  nginx;
worker_processes  1;error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;events {worker_connections  1024;
}http {# Basic configuration for vts modulevhost_traffic_status_zone shared:vhost_traffic_status:10m;include       /etc/nginx/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  /var/log/nginx/access.log  main;sendfile        on;keepalive_timeout  65;include /etc/nginx/conf.d/*.conf;
}

default.conf

server {listen       80;server_name  localhost;#charset koi8-r;#access_log  /var/log/nginx/log/host.access.log  main;location / {root   /usr/share/nginx/html;index  index.html index.htm;}location /status {vhost_traffic_status_display;vhost_traffic_status_display_format html;}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;location = /50x.html {root   /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}
}

构建

docker build -t nginx-vts:1.20.0 .

运行

docker run -d -p 80:80 nginx-vts:1.20.0

docker制作nginx+nginx-module-vts镜像基于alpine镜像相关推荐

  1. 构建haproxy镜像(基于alpine系统)

    拉取alpine系统镜像 [root@localhost ~]# docker pull alpine Using default tag: latest latest: Pulling from l ...

  2. docker制作镜像的方法

    docker镜像简介 docker镜像是分层的,有底层网上叠加下载. dockerfille是以文本的方式生成镜像,他的好处在于生成镜像后可以查看生成流程.相对于docker commit,使它更加的 ...

  3. docker使用alpine镜像

    alpine介绍 alpine简要介绍 Alpine 的意思是"高山的",比如 Alpine plants高山植物,Alpine skiing高山滑雪.the alpine res ...

  4. Alpine镜像中时区的设置

    缺省状态下Alpine镜像下的timezone会设定成UTC,相较于东八区的CST北京时间来说本地时间比UTC早了8个小时.这篇文章介绍一下时区相关的基础知识以及如何在Alpine中将时间从UTC设定 ...

  5. dockerfile安装yum_Docker镜像-基于DockerFile制作yum版nginx镜像

    Docker镜像-基于DockerFile制作yum版nginx镜像 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. DockerFile可以说是一种能被Docker程序解释的脚本, ...

  6. Docker 制作Nginx镜像

    系列文章目录 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 例如:第一章 Python 机器学习入门之pandas的使用 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮 ...

  7. docker制作nginx源码镜像

    主题 当前项目需要批量安装多个nginx服务,但是需要nginx配置支持ipv6,但是docker公有仓库的镜像并没有把这个模块加上,于是想通过centos为基础镜像,通过Dockerfile制作一个 ...

  8. CentOS7安装Docker,运行Nginx镜像、Centos镜像

    2019独角兽企业重金招聘Python工程师标准>>> 1.环境,CentOS7 Minimal 64位,Docker必须要64位的系统 2.通过yum命令直接安装,yum inst ...

  9. Docker file 搭建 Nginx镜像

    构建Nginx基础镜像 在使用 Dockerfile 之前 一定要梳理自己的步骤. 切记.切记 安装Nginx 你要启用哪些模块 Nginx初始化 启动 既然是搭建镜像那就简单地说一下,在企业中的镜像 ...

最新文章

  1. eclipse安装Spket插件
  2. ie6/IE8/IE9/谷歌以及火狐等浏览器下li 高度一致解决办法
  3. 多线程:Vector是线程安全的吗
  4. 通信之道从微积分到5gpdf_保送清华成博士,华为12年搞通信,他为何如此看待 5G ?| 人物志...
  5. 动态规划——使用最小花费爬楼梯(Leetcode 746)
  6. [鸟哥linux视频教程整理]03_03_bash特性详解续
  7. BPSK、8PSK、QPSK、16QAM、64QAM区别与联系
  8. python实现音乐播放器_【原创源码】用Python来实现一个简易的MP3播放器(采用酷我接口,包含接口分析)...
  9. 中文文本分析工具总结
  10. python新手怎么兼职-用Python在家兼职赚钱的4个方法
  11. 微信朋友验证消息是什么来源_微信好友来源朋友验证消息
  12. IDEA 在hdfs中创建目录
  13. 管理计算机找不到应用程序,Win7计算机管理提示找不到文件或没有关联的程序问题解决方法...
  14. 985、211外,你还应该清楚这些高校联盟!
  15. 笔记本电脑能连接WiFi但浏览器无法打开网页的解决办法
  16. 【学习笔记】大数据技术之Flume
  17. 函数调用过程中函数栈详解
  18. 迅为iTOP-3399平台车牌识别解决方案
  19. 苹果保修期查询_查询iPhone的保修日期和激活日期
  20. 数据库字段类型CHAR和INT

热门文章

  1. 使用ARP命令来绑定IP和MAC地址
  2. 桌面图标有蓝色阴影终极解决方法
  3. android手机禁止休眠_android设置屏幕禁止休眠的方法
  4. Few-shots object detection
  5. windows7系统登陆密码破解技巧
  6. Crontab 每两周执行一次
  7. 基于CMMI模型实现自己的总体研发框架(2)——CMMI模型-过程管理过程域介绍
  8. 字符1到数字1的路线指南
  9. 比布拉奇数列c语言,斐波那契数列与贝祖数的估计介绍
  10. 《三体》中超级悲壮的话有哪些?