上传证书到容器上传根据域名生成的证书
标签:
安置nginx容器 搜索nginx镜像 docker search nginx 拉取最新版nginx docker pull nginx:latest 运行容器 docker run --name=nginx -p 443:443 -v /nginx/conf.d:/etc/nginx/conf.d -d nginx --name=nginx: 容器名称。 -p 443:443: 端口进行映射,将本地 443 端口映射到容器内部的 443 端口。 -d nginx: 设置容器在在后台一直运行。 容器内安置sz、rz apt-get update && apt-get install lrzsz docker容器中安置vi命令 apt-get update apt-get install vim 进入容器,上传证书到容器 上传按照域名生成的证书,好比 fullchain1.pem(公钥) privkey1.pem(密钥) 监听443端口,,通过nginx代办代理应用网站 /etc/nginx/nginx.conf中插手如下配置: 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; #server是新增的配置 server { listen 443 ssl; #server_name svr.com.cn ssl_certificate fullchain1.pem; #公钥,证书 ssl_certificate_key privkey1.pem; #密钥 location / { proxy_set_header X-FORWARDED-FOR $remote_addr; proxy_set_header X-FORWARDED-PROTO $scheme; proxy_set_header Host $http_host; proxy_pass :80; #代办代理的应用 宿主机IP:容器映射到宿主机的端口 } } } 重载nginx处事 service nginx reload 将域名svr.com.cn映射到nginx地址的宿主机IP(配置DNS映射,或者改hosts文件) 通过域名访谒应用 https://svr.com.cn 检察nginx代办代理应用(svr.com.cn)访谒日志(应用容器id为 09a1c) docker logs -f 09a1cdocker使用nginx实现ssl(https)反向代办代理其他容器应用
标签:
原文地点:https://www.cnblogs.com/jun-zi/p/12189434.html
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31621.html
- 上一篇:poj3009 Curling 2.0
- 下一篇: 二、josn中传递‘\r‘