Apache代理https服务 + certbot 获取letsencrypt的https证书

安装certbot

sudo apt-get update
sudo apt-get install software-properties-common
sudo add-apt-repository universe
# ppa ( Personal Package Archives: 个人收集得数据源)
sudo add-apt-repository ppa:certbot/certbot
# 重新更新下apt源得列表
sudo apt-get update
# 安装certbot软件
sudo apt-get install certbot

获取证书:

# 获取证书,-d 可以指定多个参数 -d www.domain2.com -d www.domain1.com 
# 生成的证书地址 /etc/letsencrypt/live/www.domain2.com/
# 证书的地址都是符号链接 真实文件地址  /etc/letsencrypt/archives/www.domain2.com/
# 除了--standonly 还有--webroot --webroot-path=/var/html/www/www/domain2.com
# 开始前先将监听80端口的应用暂时关闭

certbot certonly --standonly -d www.domain.com

certbot certonly --webroot --webroot-path=/var/html/www/www.domain2.com -d www.domain.com

注意:

1. 需要将apache停用,在ubuntu上建议使用apache2ctl stop

 

配置apache代理服务器

<VirtualHost *:443>
    ServerAdmin www.domain.com
    ServerName www.domain.com
SSLProxyEngine on
# 如果真实服务器是自签证书,建议不验证https的有效性
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ProxyRequests Off
# 此处不能省略域名后的 / 
ProxyPass / https://www.domain.com/
ProxyPassReverse / https://www.domain.com/

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
    SSLEngine on
# 此处为代理服务器的真实证书
    SSLCertificateFile /etc/letsencrypt/live/www.domain.com/fullchain.pem
    SSLCertifiCateKeyFile /etc/letsencrypt/live/www.domain.com/privkey.pem
    DirectoryIndex index.php index.html
</VirtualHost>

 

转载于:https://my.oschina.net/u/3054299/blog/2993334

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值