阿里云有免费证书,地址:数字证书管理服务管理控制台 - 概览 (aliyun.com)
免费证书好像要达到什么条件才有,一般域名多肯定有的。
官方基于nginx的教程:在Nginx或Tengine服务器上安装证书 (aliyun.com)
而我们,是要在docker基础上创建nginx并部署ssl,所以有两个东西不能搞错,文件映射和端口映射。笔者搞的时候就漏了443端口忘记映射所以不能成功卡了挺久。
废话不多说,直接上代码。
docker-compose.yml
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18version: '3.3' services: nginx: image: nginx restart: always hostname: nginx container_name: nginx privileged: true ports: - 80:80 - 443:443 volumes: - /usr/local/docker-compose/nginx/conf/nginx.conf:/etc/nginx/nginx.conf - /usr/local/docker-compose/nginx/conf.d/:/etc/nginx/conf.d/ - /usr/local/docker-compose/nginx/www/:/usr/share/nginx/html/ - /usr/local/docker-compose/nginx/logs/:/var/log/nginx/ - /usr/local/docker-compose/nginx/ssl/:/etc/nginx/ssl/ - /usr/local/kuaishou/:/usr/local/kuaishou/
ssl.conf,替换其中域名,路径不能错,一定要是容器nginx里的路径
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17server { listen 443 ssl; server_name baidu.com; root html; index index.html index.htm; ssl_certificate /etc/nginx/ssl/baidu.com.pem; ssl_certificate_key /etc/nginx/ssl/baidu.com.key; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; location / { root html; index index.html index.htm; } }
小白记得把nginx的配置nginx.conf改一下
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31user nginx; worker_processes auto; error_log /var/log/nginx/error.log notice; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; }
最后
以上就是谨慎香氛最近收集整理的关于docker-compose创建nginx并部署ssl证书,阿里云ssl证书的全部内容,更多相关docker-compose创建nginx并部署ssl证书内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复