Docker image for nginx http2

2015-10-28 02:03:10 +08:00
 hyuwang

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

Docker hub
Github

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

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

功能上来说,比起传统的虚拟机 docker 的容器不能虚拟化内核,但性能上与宿主机保持一致( container 作为一个进程运行,没有性能损失)
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
2015-10-28 03:31:26 +08:00
@hyuwang Docker 的存储是有一定的性能损失的,还有网络
其实测试的话,性能损失没什么关系,最主要是 Docker 部署方便
hyuwang
2015-10-28 03:58:39 +08:00
@lhbc 嗯,自行编译的话 libressl 是个好选择,从 openssl 编译的话坑挺多的,得改一下 nginx source 里的配置

docker 这块确实是,上一个回复没说清...应该说基本没什么性能损失
ryd994
2015-10-28 04:23:25 +08:00
centos7 直接装官方包没有问题
hyuwang
2015-10-28 04:49:27 +08:00
@ryd994 据我所知目前各大发行版官方源里都应该没有 openssl 1.0.2 和带 http2module 的 nginx
你确定直接装的能用 http2 ?
vibbow
2015-10-28 06:38:23 +08:00
@hyuwang 听起来和 OpenVZ 差不多
hyuwang
2015-10-28 08:38:32 +08:00
@vibbow 功能上区别不大 docker 完全基于 linux lxc 的内核特性 轻量化是最大的特点 容器打开关闭不过一两秒的事
millson
2015-10-28 08:44:07 +08:00
http://nginx.org/en/linux_packages.html#mainline 针对各个发行版的, mainline 版本默认用 --with-http_v2_module 替代了 --with-http_spdy_module
ryd994
2015-10-28 11:12:38 +08:00
@hyuwang 是我没说清楚。我说的是 nginx 官方源: http://nginx.org/packages/mainline/
见 @milson 的回复
hyuwang
2015-10-28 17:24:00 +08:00
@millson 赞啊 这个省心多了

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/231591

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX