|
|

楼主 |
发表于 2026-6-14 23:21
|
显示全部楼层
- ---------------------------------
- 在无痕模式下,域名直接访问的时候会提示没有https
- 那么还是同时也给域名申请证书吧
- 运行下面的命令
- docker run -it --rm \
- -v /root/docker/lamp/httpd/apache2/htdocs/域名.com/zhengshu:/etc/letsencrypt \
- -v /root/docker/lamp/httpd/apache2/htdocs/域名.com/www:/var/www/html \
- certbot/certbot certonly --webroot \
- -w /var/www/html \
- -d 域名.com -d www.域名.com \
- -m webmaster@域名.com
- ---------------------------------
- 运行以后结果如下:
- Saving debug log to /var/log/letsencrypt/letsencrypt.log
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- You have an existing certificate that contains a portion of the domains you
- requested (ref: /etc/letsencrypt/renewal/www.域名.com.conf)
- It contains these names: www.域名.com
- You requested these names for the new certificate: 域名.com,
- www.域名.com.
- Do you want to expand and replace this existing certificate with the new
- certificate?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- (E)xpand/(C)ancel: E
- Renewing an existing certificate for 域名.com and www.域名.com
- Successfully received certificate.
- Certificate is saved at: /etc/letsencrypt/live/www.域名.com/fullchain.pem
- Key is saved at: /etc/letsencrypt/live/www.域名.com/privkey.pem
- This certificate expires on 2026-09-12.
- These files will be updated when the certificate renews.
- NEXT STEPS:
- - The certificate will need to be renewed before it expires. Certbot can automatically renew the certificate in the background, but you may need to take steps to enable that functionality. See https://certbot.org/renewal-setup for instructions.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- If you like Certbot, please consider supporting our work by:
- * Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
- * Donating to EFF: https://eff.org/donate-le
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- ---------------------------------
- 然后顺便给域名也同时配置一个https
- <VirtualHost _default_:443>
- DocumentRoot "/usr/local/apache2/htdocs/域名.com/www"
- ServerName 域名.com:443
- ServerAdmin webmaster@域名.com
- ErrorLog /proc/self/fd/2
- TransferLog /proc/self/fd/1
- SSLEngine on
- SSLCertificateFile "/usr/local/apache2/htdocs/域名.com/zhengshu/live/www.域名.com/fullchain.pem"
- SSLCertificateKeyFile "/usr/local/apache2/htdocs/域名.com/zhengshu/live/www.域名.com/privkey.pem"
- SSLCertificateChainFile "/usr/local/apache2/htdocs/域名.com/zhengshu/live/www.域名.com/chain.pem"
- <FilesMatch "\.(cgi|shtml|phtml|php)$">
- SSLOptions +StdEnvVars
- </FilesMatch>
- <Directory "/usr/local/apache2/cgi-bin">
- SSLOptions +StdEnvVars
- </Directory>
- BrowserMatch "MSIE [2-5]" \
- nokeepalive ssl-unclean-shutdown \
- downgrade-1.0 force-response-1.0
- CustomLog /proc/self/fd/1 \
- "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x "%r" %b"
- </VirtualHost>
- 删掉多余的注释以后就这么多,我是直接复制默认的配置的,这样配置没啥问题
- ---------------------------------
- 最后在无痕模式下,直接域名访问,也能正常https,查看证书是域名
- 然后用www访问也能https,这里查看证书也是不带www的域名,那么未来每次弄-d参数还是都带上吧
复制代码 |
|