V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hyuwang
V2EX  ›  Docker

Docker image for nginx http2

  •  
  •   hyuwang · 2015-10-28 02:03:10 +08:00 · 4023 次点击
    这是一个创建于 3117 天前的主题,其中的信息可能已经有所发展或是发生改变。

    看到很多人想尝鲜 http2 ,但编译 openssl 和 nginx 比较繁琐,就做了个 docker image 方便大家。
    除了预装 openssl 1.0.2 和加入 http2 module ,其余和官方的 nginx image 完全保持一致(包括所有配置文件位置),目前没做优化,大小为 400+MB 。

    Docker hub
    Github

    经测试可以完美替换官方 nginx image 无需任何改动
    对 Docker 稍有了解的话应该很容易上手

    12 条回复    2015-10-28 17:24:00 +08:00
    vibbow
        1
    vibbow  
       2015-10-28 02:10:45 +08:00
    docker 和传统的虚拟机有什么区别么?
    hyuwang
        2
    hyuwang  
    OP
       2015-10-28 02:22:10 +08:00
    @vibbow 应该说完全不同, docker 是一个管理容器的引擎,负责打包 image 和管理容器( container ),容器可以近似理解为和外界隔离的黑箱,运用了 linux 新内核带来的虚拟化技术,可以使应用变得轻量易部署(拥有统一的环境,保证开发环境和生产环境的一致性,极大减轻运维负担)。

    功能上来说,比起传统的虚拟机 docker 的容器不能虚拟化内核,但性能上与宿主机保持一致( container 作为一个进程运行,没有性能损失)
    lhbc
        3
    lhbc  
       2015-10-28 03:28:11 +08:00
    这样编译就行了,和官方 rpm 的参数差不多
    SSL 可以用 libressl-2.3.0 或者 openssl-1.0.2d

    ./configure --prefix=/usr/local/nginx \
    --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_v2_module \
    --with-http_realip_module \
    --with-http_addition_module \
    --with-http_sub_module \
    --with-http_dav_module \
    --with-http_mp4_module --with-http_flv_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-stream --with-stream_ssl_module \
    --with-mail --with-mail_ssl_module \
    --with-file-aio \
    --with-ipv6 \
    --with-threads \
    --with-openssl=../libressl-2.3.0 \
    --with-pcre \
    --with-zlib
    lhbc
        4
    lhbc  
       2015-10-28 03:31:26 +08:00
    @hyuwang Docker 的存储是有一定的性能损失的,还有网络
    其实测试的话,性能损失没什么关系,最主要是 Docker 部署方便
    hyuwang
        5
    hyuwang  
    OP
       2015-10-28 03:58:39 +08:00
    @lhbc 嗯,自行编译的话 libressl 是个好选择,从 openssl 编译的话坑挺多的,得改一下 nginx source 里的配置

    docker 这块确实是,上一个回复没说清...应该说基本没什么性能损失
    ryd994
        6
    ryd994  
       2015-10-28 04:23:25 +08:00
    centos7 直接装官方包没有问题
    hyuwang
        7
    hyuwang  
    OP
       2015-10-28 04:49:27 +08:00
    @ryd994 据我所知目前各大发行版官方源里都应该没有 openssl 1.0.2 和带 http2module 的 nginx
    你确定直接装的能用 http2 ?
    vibbow
        8
    vibbow  
       2015-10-28 06:38:23 +08:00
    @hyuwang 听起来和 OpenVZ 差不多
    hyuwang
        9
    hyuwang  
    OP
       2015-10-28 08:38:32 +08:00
    @vibbow 功能上区别不大 docker 完全基于 linux lxc 的内核特性 轻量化是最大的特点 容器打开关闭不过一两秒的事
    millson
        10
    millson  
       2015-10-28 08:44:07 +08:00   ❤️ 1
    http://nginx.org/en/linux_packages.html#mainline 针对各个发行版的, mainline 版本默认用 --with-http_v2_module 替代了 --with-http_spdy_module
    ryd994
        11
    ryd994  
       2015-10-28 11:12:38 +08:00
    @hyuwang 是我没说清楚。我说的是 nginx 官方源: http://nginx.org/packages/mainline/
    见 @milson 的回复
    hyuwang
        12
    hyuwang  
    OP
       2015-10-28 17:24:00 +08:00
    @millson 赞啊 这个省心多了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   969 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 20:50 · PVG 04:50 · LAX 13:50 · JFK 16:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.