-
-
Notifications
You must be signed in to change notification settings - Fork 224
/
Copy pathnginx.conf
157 lines (126 loc) · 4.56 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
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
client_max_body_size 50M;
# Enable gzip compression
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_http_version 1.1;
# Redirect www.91huajian.cn to maobucv.com
server {
listen 80;
server_name www.91huajian.cn;
return 301 https://maobucv.com$request_uri;
}
server {
listen 443 ssl;
server_name www.91huajian.cn;
ssl_certificate /etc/nginx/ssl/fullchain.crt;
ssl_certificate_key /etc/nginx/ssl/private.pem;
return 301 https://maobucv.com$request_uri;
}
# Redirect 91huajian.cn to maobucv.com
server {
listen 80;
server_name 91huajian.cn;
return 301 https://maobucv.com$request_uri;
}
server {
listen 443 ssl http2;
server_name 91huajian.cn;
ssl_certificate /etc/nginx/ssl/fullchain.crt;
ssl_certificate_key /etc/nginx/ssl/private.pem;
return 301 https://maobucv.com$request_uri;
}
# Redirect www.maobucv.com to maobucv.com
server {
listen 80;
server_name www.maobucv.com;
return 301 https://maobucv.com$request_uri;
}
server {
listen 443 ssl;
server_name www.maobucv.com;
ssl_certificate /etc/nginx/ssl/maobucv.crt;
ssl_certificate_key /etc/nginx/ssl/maobucv.pem;
return 301 https://maobucv.com$request_uri;
}
# Handle requests for maobucv.com
server {
listen 80;
server_name maobucv.com;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
}
server {
listen 443 ssl http2;
server_name maobucv.com;
ssl_certificate /etc/nginx/ssl/maobucv.crt;
ssl_certificate_key /etc/nginx/ssl/maobucv.pem;
# Let WordPress through subdirectory access
location ^~ /articles/ {
client_max_body_size 50M;
rewrite ^/articles(/.*)$ $1 break;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://119.91.202.144:3210/;
}
# Redirect pages
location ~ /wp-(admin|login|content|includes)/ {
client_max_body_size 50M;
return 301 /articles$request_uri;
}
# Forward requests to the prerender service
location / {
set $prerender 0;
# Check user agent for bots and crawlers
if ($http_user_agent ~* (googlebot|bingbot|yandex|baiduspider|sogouspider|haosouSpider|sm|yahoo|msnbot|exabot|facebot|ia_archiver|applebot|slurp|gigabot|teoma|twiceler|rogerbot|voila|findlink|naverbot|curl|wget)) {
set $prerender 1;
}
# Proxy request to the prerender service
if ($prerender = 1) {
error_page 500 502 503 504 = @fallback_to_static;
rewrite ^/(.*)$ /huajian/render/$1 break; # Correctly handle the path
proxy_pass http://119.91.202.144:3399; # Ensure this points to your prerender service
break;
}
# Serve static files
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# Fallback location to serve static files in case of errors
location @fallback_to_static {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
# Forward /huajian interface to specified address
location /huajian {
proxy_connect_timeout 600s;
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://119.91.202.144:3399/huajian;
}
# Handle Vue router refresh
location @router {
rewrite ^.*$ /index.html last;
}
}
}