forked from rong6/jsd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx.conf
54 lines (44 loc) · 1.71 KB
/
nginx.conf
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
48
49
50
51
52
53
54
server {
listen 80;
listen 443 ssl http2;
server_name 1.jsd.050466.xyz; #需要换成你这个站点的域名
root /www/wwwroot/1.jsd.050466.xyz; #宝塔默认目录,换成你自己的域名或你主页文件的所在目录
location = / {
index index.html; #如果主页是PHP文件改成index.php即可
}
location / {
try_files $uri $uri/ @proxy;
}
location @proxy {
proxy_pass https://cdn.jsdelivr.net;
proxy_set_header Host cdn.jsdelivr.net;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
add_header X-Cache $upstream_cache_status;
#Set Nginx Cache
#缓存设置,可在下面配置要缓存的文件扩展名
if ( $uri ~* "\.(gif|png|jpg|css|js|webp)$" ) {
expires 24h; #缓存时间
}
proxy_ignore_headers Set-Cookie Cache-Control expires;
proxy_cache cache_one;
proxy_cache_key $host$uri$is_args$args;
proxy_cache_valid 200 304 301 302 1440m;
proxy_max_temp_file_size 5m; #为了防止文件过大浪费带宽,可设置返回文件大小限制
proxy_intercept_errors on;
error_page 413 /custom_413.html;
}
location = /custom_413.html {
root /www/wwwroot/1.jsd.050466.xyz;
internal;
default_type text/html;
return 200 '文件超过5MB,不予返回!';
}
#SSL配置
#SSL start
#SSL end
}