nginx生成https 证书-基于docker-compose

申请的证书存放nginx的docker-compose.yml同一目录

复制代码
[root@k8s-node1 nginx]# cat docker-compose.yml 
version: '2'
services:
  nginx:
    container_name: nginx
    image: nginx
    restart: always
    volumes:
      - "./default.conf:/etc/nginx/conf.d/default.conf"
      - "./nginx.conf:/etc/nginx/nginx.conf"
      - "./oetsky.com.crt:/etc/nginx/oetsky.com.crt"
      - "./oetsky.com.key:/etc/nginx/oetsky.com.key"
    ports:
      - "80:80"
      - "30080:30080"
复制代码
复制代码
[root@k8s-node1 nginx]# cat default.conf 
server {
    listen       30080 ssl ;
    server_name  mgedu.com;
    ssl_certificate   oetsky.com.crt;
    ssl_certificate_key  oetsky.com.key;
    charset utf-8;    
    #location ~* \.(css|js|png|jpg|jpeg|gif|gz|svg|mp4|ogg|ogv|webm|htc|xml|woff)$ {
    #        add_header Cache-Control max-age=604800; # 不起作用
    #    }

    location / {
        root   /usr/share/nginx/html;
        try_files $uri $uri/ /index.html;
        index  index.html index.htm;
         if ($request_filename ~* .*\.(htm|html)$){
            add_header Cache-Control "no-store";
       }
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

复制代码

 

posted @   beawh  阅读(84)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
历史上的今天:
2022-10-10 哈哈 之前忘记收藏了
2021-10-10 redolog落盘机制
2021-10-10 MySQL中Redo Log相关的重要参数总结
2021-10-10 mysql之innodb_buffer_pool
点击右上角即可分享
微信分享提示