使用Docker编译OpenResty支持国密ssl加密

本文涉及的产品
密钥管理服务KMS,1000个密钥,100个凭据,1个月
简介: OpenResty自身支持标准SSL协议,但不支持国密SSL协议;本文主要概述如何在docker环境下编译OpenResty镜像支持国密SSL加密。

编译环境

执行编译操作环境如下

#操作系统
CentOS Linux release 7.4.1708 (Core)
#docker版本
 Version:           19.03.5

编译过程

Dockerfile如下

FROM centos:7

WORKDIR  /usr/local/gm-openresty
# 安装所需依赖包
RUN yum -y install perl make gcc gcc-c++ libstdc++-devel pcre-devel zlib-devel net-tools pcre wget && \
yum clean all && \
wget https://www.gmssl.cn/gmssl/Tool_Down?File=gmssl_openssl_1.1_b4.tar.gz && tar xzfm Tool_Down?File=gmssl_openssl_1.1_b4.tar.gz -C /usr/local && \
wget https://openresty.org/download/openresty-1.19.3.1.tar.gz && tar xzfm openresty-1.19.3.1.tar.gz && \
ln -s /usr/lib64/libpcre.so.1 /usr/lib64/libpcre.so.3

RUN sed -i 's#$OPENSSL/.openssl/#$OPENSSL/#p' /usr/local/gm-openresty/openresty-1.19.3.1/bundle/nginx-1.19.3/auto/lib/openssl/conf && \
cd openresty-1.19.3.1/ && \
./configure \
--without-http_gzip_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_v2_module \
--with-file-aio \
--with-openssl="/usr/local/gmssl" \
--with-cc-opt="-I/usr/local/gmssl/include" \
--with-ld-opt="-lm" && \
make install && \
rm -rf /usr/local/gm-openresty/* && \
ln -sf /dev/stdout /usr/local/openresty/nginx/logs/access.log && \
ln -sf /dev/stderr /usr/local/openresty/nginx/logs/error.log

# Add additional binaries into PATH for convenience
ENV PATH=$PATH:/usr/local/openresty/luajit/bin:/usr/local/openresty/nginx/sbin:/usr/local/openresty/bin

EXPOSE 80 443
CMD ["/usr/bin/openresty", "-g", "daemon off;"]

# Use SIGQUIT instead of default SIGTERM to cleanly drain requests
# See https://github.com/openresty/docker-openresty/blob/master/README.md#tips--pitfalls
STOPSIGNAL SIGQUIT
  • 构建镜像
docker build -t openresty-gm:v1 .
  • 启动
$ docker run -it -p 80:80 -p 443:443  -v /root/openresty/cert:/usr/local/cert -v /root/openresty/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf  openresty-gm:v1 bash

#在容器中执行openresty命令即可启动
$ openresty

nginx.conf 内容

worker_processes  2;
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;


    sendfile        on;
    keepalive_timeout  65;

   server
    {
      listen 0.0.0.0:80;
      listen 0.0.0.0:443 ssl;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:AES128-SHA:DES-CBC3-SHA:ECC-SM4-CBC-SM3:ECDHE-SM4-GCM-SM3;
      ssl_verify_client off;

      ssl_certificate /usr/local/cert/test.cn_RSA.crt;
      ssl_certificate_key /usr/local/cert/test.cn_RSA.key;

      ssl_certificate /usr/local/cert/test.cn_sm2_sign.crt;
      ssl_certificate_key /usr/local/cert/test.cn_SM2.key;

      ssl_certificate /usr/local/cert/test.cn_sm2_encrypt.crt;
      ssl_certificate_key /usr/local/cert/test.gov.cn_SM2.key;

      location /
      {
        root html;
        index index.html index.htm;
      }
   }
}
  • 客户端使用360安全浏览器访问

参考文章

相关文章
|
2月前
|
Kubernetes Devops 持续交付
DevOps实践:使用Docker和Kubernetes实现持续集成和部署网络安全的守护盾:加密技术与安全意识的重要性
【8月更文挑战第27天】本文将引导读者理解并应用DevOps的核心理念,通过Docker和Kubernetes的实战案例,深入探讨如何在现代软件开发中实现自动化的持续集成和部署。文章不仅提供理论知识,还结合真实示例,旨在帮助开发者提升效率,优化工作流程。
|
2天前
|
算法 小程序 网络安全
阿里云WoSign SSL证书,RSA和国密有什么区别?_沃通SSL技术文档
阿里云WoSign品牌SSL证书为用户提供国密合规SM2算法SSL证书、全球信任RSA算法SSL证书,全球信任、国密合规,能够满足阿里云平台用户不同的SSL证书应用需求。那么阿里云WoSign SSL证书分别提供的RSA算法和国密算法,有什么区别呢?
20 5
|
2天前
|
应用服务中间件 网络安全 Apache
Discuz! X3.5 开启ssl证书加密后微信、公众号无消息、支付宝通讯中断等
Discuz! X3.5 开启ssl证书加密后微信、公众号无消息、支付宝通讯中断等、支付宝支付实际支付成功,显示未支付等,都属于通讯中断,需要联系DZ官方付费修改程序,屏蔽防CC!
11 4
|
1月前
|
应用服务中间件 nginx Docker
Docker镜像-基于DockerFile制作编译版nginx镜像
这篇文章介绍了如何基于Dockerfile制作一个编译版的nginx镜像,并提供了详细的步骤和命令。
282 17
Docker镜像-基于DockerFile制作编译版nginx镜像
|
5月前
|
NoSQL 测试技术 Go
【Golang】国密SM2公钥私钥序列化到redis中并加密解密实战_sm2反编(1)
【Golang】国密SM2公钥私钥序列化到redis中并加密解密实战_sm2反编(1)
|
2月前
|
Android开发 Docker 容器
docker中编译android aosp源码,出现Build sandboxing disabled due to nsjail error
在使用Docker编译Android AOSP源码时,如果遇到"Build sandboxing disabled due to nsjail error"的错误,可以通过在docker run命令中添加`--privileged`参数来解决权限不足的问题。
349 1
|
4月前
|
敏捷开发 API 持续交付
阿里云云效产品使用问题之流水线编译docker时,如何把已经定义好的token传入编译参数
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
阿里云云效产品使用问题之流水线编译docker时,如何把已经定义好的token传入编译参数
|
2月前
|
jenkins 网络安全 持续交付
Jenkins Pipeline 流水线 - 上传文件 Publish over SSH + Docker 编译 + 上传到阿里仓库
Jenkins Pipeline 流水线 - 上传文件 Publish over SSH + Docker 编译 + 上传到阿里仓库
91 0
|
2月前
|
SQL 安全 Java
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
驱动程序无法通过使用安全套接字层(SSL)加密与 SQL Server 建立安全连接。错误:“The server selected protocol version TLS10 is not accepted by client
324 0
|
3月前
|
安全 网络协议 网络安全
SSL(Secure Sockets Layer)是一种安全协议,用于在客户端和服务器之间建立加密的通信通道。
SSL(Secure Sockets Layer)是一种安全协议,用于在客户端和服务器之间建立加密的通信通道。

热门文章

最新文章