当前位置: 首页> 房产> 市场 > 合肥房产网二手房出售_上海装修公司前100名_免费seo教程资源_网站内链优化

合肥房产网二手房出售_上海装修公司前100名_免费seo教程资源_网站内链优化

时间:2025/7/13 9:18:45来源:https://blog.csdn.net/qq_34988204/article/details/147137360 浏览次数:1次
合肥房产网二手房出售_上海装修公司前100名_免费seo教程资源_网站内链优化

【Docker】快速部署 Certbot 并为 Nginx 服务器配置 SSL/TLS 证书

引言

Certbot 是一个免费的开源工具,用于自动化管理和获取 SSL/TLS 证书,主要用于与 Let’s Encrypt 证书颁发机构交互。

步骤

  1. Nginx 挂载 certbot 文件夹。
docker run -d \--name nginx \-p 80:80 \-p 443:443 \-v "$(pwd)/nginx/nginx.conf:/etc/nginx/nginx.conf" \-v "$(pwd)/nginx/conf.d:/etc/nginx/conf.d" \-v "$(pwd)/nginx/log:/var/log/nginx" \-v "$(pwd)/nginx/html:/usr/share/nginx/html" \-v "$(pwd)/certbot/www:/usr/share/certbot/www:ro" \-v "$(pwd)/certbot/ssl:/usr/share/certbot/ssl:ro" \--restart always \nginx:latest
  1. 修改 Nginx 配置文件 default.conf。
server {listen       80;listen  [::]:80;server_name  example.com www.example.com;location /.well-known/acme-challenge/ {root /usr/share/certbot/www;}location / {root   /usr/share/nginx/html;try_files $uri $uri/ /index.html last;index  index.html index.htm;}
}
  1. 创建证书(仅需运行一次)
docker run --rm \-v "$(pwd)/www:/usr/share/certbot/www:rw" \-v "$(pwd)/ssl:/etc/letsencrypt:rw" \certbot/certbot certonly \--webroot -w /usr/share/certbot/www \-d example.com \-d www.example.com \--non-interactive \--agree-tos \--expand \-m example@example.com
  1. 修改 Nginx 配置文件 default.conf,启用 SSL 证书。
server {listen       80;listen  [::]:80;server_name  example.com www.example.com;location /.well-known/acme-challenge/ {root /usr/share/certbot/www;}location / {return 301 https://$host$request_uri;}
}server {listen       443 ssl;listen  [::]:443 ssl;server_name  example.com www.example.com;ssl_certificate /usr/share/certbot/ssl/live/example.com/fullchain.pem;ssl_certificate_key /usr/share/certbot/ssl/live/example.com/privkey.pem;location / {root   /usr/share/nginx/html;try_files $uri $uri/ /index.html last;index  index.html index.htm;}
}
  1. https 启用成功
关键字:合肥房产网二手房出售_上海装修公司前100名_免费seo教程资源_网站内链优化

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: