免费证书申请


公网 IP SSL 证书

示例:https://106.54.251.56


ssl配置

IP证书nginx配置为例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
server {
listen 80 default_server;
listen [::]:80 default_server;
location / {
add_header "AccessControll-Allow-Origin" "*";
root /home/www;
index index.html index.htm test.html demo.html;
}
return 301 https://$host$request_uri;
}

server {

listen 443 ssl http2;
# listen [::]:443 ssl http2;

ssl_certificate /etc/nginx/conf.d/182.61.6.105.crt;
ssl_certificate_key /etc/nginx/conf.d/182.61.6.105.key;
ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
ssl_session_tickets off;

# curl https://certbase.com/ffdhe2048.txt > /path/to/dhparam
# ssl_dhparam /path/to/dhparam;
# intermediate configuration
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
ssl_prefer_server_ciphers off;

# HSTS (ngx_http_headers_module is required) (63072000 seconds)
# add_header Strict-Transport-Security "max-age=63072000"always;

# OCSP stapling
ssl_stapling on;
ssl_stapling_verify on;

# verify chain of trust of OCSP response using Root CA and Intermediate certs
# ssl_trusted_certificate /path/to/root_CA_cert_plus_intermediates;

# replace with the IP address of your resolver
# resolver 127.0.0.1;
location / {
add_header "AccessControll-Allow-Origin" "*";
root /home/www;
index index.html index.htm test.html demo.html;
}
}

使用 caddy 自动代理并生成ssl

  • systemctl stop caddy.service停止caddy服务

小技巧

  • 配置完不生效?添加防火墙端口白名单firewall-cmd --add-port=443/tcp --permanent,并重启防火墙firewall-cmd --reload
  • 证书的有效期好像都是一年,完了要重新申请配置