certbot生成免費證書


1. 下載 certbot(https://certbot.eff.org) https://github.com/certbot/certbot
2.生成證書時需要配置的nginx
server
{
listen 80;
server_name gzmp.xxx.com;
location ^~ /.well-known/acme-challenge/ {
default_type "text/plain";
root D:/IISWeb/gzmp;
}
 
location = /.well-known/acme-challenge/ {
return 404;
}
access_log logs/www_access.log;
}
 
3.測試nginx配置是否正確
nginx -t
4.重啟nginx
nginx -s reload
5.certbot生成證書(create_certbot.bat)
certbot certonly --webroot --email dev@xxx.com -w D:/IISWeb/gzmp -d gzmp.xxx.com
6.certbot手動更新證書(renew_certbot.bat)
certbot renew -v
7.certbot自動更新證書(auto_renew_certbot.bat)
certbot renew --quiet --no-self-upgrade
生成成功后,C盤的Certbot文件夾下面會出現一個live文件夾。里面有一個以你配置的網站的域名為名稱的文件夾。
8.生成證書后,修改nginx配置,重復3、4步驟。
配置1.
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name gzmp.xxx.com;
root D:/IISWeb/gzmp;
 
# SSL
ssl_certificate C:\Certbot\live\gzmp.xxx.com\fullchain.pem;
ssl_certificate_key C:\Certbot\live\gzmp.xxx.com\privkey.pem;
 
# index.php
index index.html index.htm index.php;
}
server
{
listen 80;
server_name gzmp.xxx.com;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:82;
}
access_log logs/www_access.log;
}
配置2.
server {
listen 443 ssl;
listen [::]:443 ssl;
server_name gzmp.xxx.com;
#root D:\AppHome\PatrolLine\portal\wwwroot;
 
# security
include default/security.conf;
 
# logging
access_log logs/gzmp.xxx.com.access.log;
error_log logs/gzmp.xxx.com.error.log warn;
 
# SSL
ssl_certificate C:\Certbot\live\gzmp.xxx.com\fullchain.pem;
ssl_certificate_key C:\Certbot\live\gzmp.xxx.com\privkey.pem;
 
# index.php
#index index.html index.htm index.php;
 
location ^~/mp/ {
root D:\AppHome\PatrolLine\miniprogram;
}
# reverse proxy
location / {
proxy_pass http://127.0.0.1:9980;
include default/proxy.conf;
}
 
# additional config
include default/general.conf;
}
server {
listen 80;
listen [::]:80;
server_name gzmp.xxx.com;
root public;
 
location / {
return 301 https://gzmp.xxx.com$request_uri;
}
}
mp目錄結構
瀏覽器訪問 https://gzmp.xxx.com/mp/
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM