为Typecho设置腾讯云CDN

  • CDN功能为Github-Material主题自带
  • 服务器运行环境LNMP
  • acme.sh自动续签Let’s Encrypt证书

配置子域名


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
server {
listen 80;
listen 443 ssl http2;
ssl_certificate /path/to/crt;
ssl_certificate_key /path/to/key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
ssl_prefer_server_ciphers on;
ssl_session_timeout 10m;
ssl_session_cache builtin:1000 shared:SSL:10m;
ssl_buffer_size 1400;
add_header Strict-Transport-Security max-age=15768000;
ssl_stapling on;
ssl_stapling_verify on;
server_name cdn.szc.me;
access_log /data/wwwlogs/cdn.szc.me_nginx.log combined;
index index.html index.htm;
root /data/wwwroot/szc.me/usr/themes/material;
if ($ssl_protocol = "") { return 301 https://$host$request_uri; }

#error_page 404 /404.html;
#error_page 502 /502.html;

add_header Access-Control-Allow-Origin https://szc.me;

location /usr/uploads/ {
root /data/wwwroot/szc.me;
}
location ~* ^/.*.(php)$ {
deny all;
}
}

腾讯云添加CDN域名


  1. 添加域名,设置子域名CNAME
  2. 设置防盗链
  3. 配置https证书

修改主题CDN


控制台-外观-设置外观-功能设置-CDN类型-自定义
填上你配置好的子域名

大功告成

将上传好文件地址中的域名修改成cdn的域名即可