CasperG's Blog

Some People choose to see the ugliness in the world, the disarray. I choose to see the beauty.

记录一次博客失效的解决方案

记录一次博客失效的解决方案


今儿早上登录Blog的时候发现页面又变成了万恶的Movie Theater…… 2021年2月23号曾经出现过这种情况,产生原因至今未知。

出现原因:

/etc/nginx/nginx.conf 配置文件出现问题。

解决方案:

重新编写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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
user  nginx;
worker_processes 1;

error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include /etc/nginx/mime.types;
default_type application/octet-stream;

log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

keepalive_timeout 65;

#gzip on;

include /etc/nginx/conf.d/*.conf;

server{
listen 443 ssl;
server_name www.gurh16.top;
ssl_certificate /home/wwwroot/www.gurh16.top/ssl/1_www.gurh16.top_bundle.crt;
ssl_certificate_key /home/wwwroot/www.gurh16.top/ssl/2_www.gurh16.top.key; #证书绝对路径
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA_AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /home/wwwroot/blog/public; #网站根目录绝对路径
index index.html index.htm;
try_files $uri $uri/ =404; #可不加,试错
}
}

server {
listen 443 ssl;
server_name blog.gurh16.top;
ssl_certificate /home/wwwroot/blog/ssl/1_blog.gurh16.top_bundle.crt; #ssl证书路径
ssl_certificate_key /home/wwwroot/blog/ssl/2_blog.gurh16.top.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA_AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
location / {
root /home/wwwroot/blog/public;
index index.html index.htm;
try_files $uri $uri/ =404;
}
}

server {
listen 80;
server_name www.gurh16.top;
rewrite ^/(.*)$ https://www.gurh16.top:443/$1 permanent; #将80重定向至443
}

server {
listen 80;
server_name blog.gurh16.top;
rewrite ^/(.*)$ https://blog.gurh16.top:443/$1 permanent;
}

# test
server {
listen 80 default_server;
server_name _;
location / {
root /home/wwwroot/blog/public;
index index.html index.htm;
try_files $uri $uri/ =404;
}
}
}

修改完成之后使用 nginx -s reload刷新配置文件。