使用Docker安装的nginx配置HTTPS证书

新建ssl.conf,将文件放入conf.d文件夹中

server {
        listen 443;
        server_name localhost;
        ssl on;
        root html;
        index index.html index.htm;
        ssl_certificate   cert/1533224843981.pem;
        ssl_certificate_key  cert/1533224843981.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        location / {
            root html;
            index index.html index.htm;
        }
    }
  • 注意点:cert为相对路径,若是linux文件夹与nginx.conf,若是window则在conf文件夹下。

运行

 docker run --name mynginx -p 443:443 -v /opt/data/nginx/nginx.conf:/etc/nginx/nginx.conf
 -v /opt/data/nginx/conf.d:/etc/nginx/conf.d/default.conf 
-v /opt/data/nginx/www:/www -v /opt/data/nginx/cert:/etc/nginx/cert 
-v /opt/data/nginx/ssl.conf:/etc/nginx/conf.d/ssl.conf -d nginx
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 说到Nginx服务器,个人认为最大特点就是轻量级和高性能。通过在几台不同的服务器上进行测试,发现它的并发能力特别强...
    ucanfirst阅读 607评论 0 0
  • 1. 去阿里云或者腾讯云申请免费的ssl证书,这里以阿里云为例。成功以后获得两个文件以.key和.pem结尾的文件...
    亦亦嘟嘟阅读 489评论 0 0
  • I/O模型: 阻塞型、非阻塞型、复用型、信号驱动型、异步 同步/异步:关注消息通知机制 消息通知:同步:等待对方返...
    Net夜风阅读 2,048评论 0 1
  • 本例在Windows下测试 **** 在Linux下步骤基本一样,Nginx在编译的时候需要支持--with...
    Notonlyphper阅读 957评论 0 1
  • 数学老师今天就给了我们十怎么写。语文老师今天教给了我们我饿一无语怎么写,那老师今天就给了我们怎么遇到他,怎么唱歌。...
    张若涵阅读 114评论 0 0