-
Notifications
You must be signed in to change notification settings - Fork 17
/
nginx.conf
78 lines (63 loc) · 1.89 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
events {}
http {
access_log /dev/stdout;
error_log /dev/stderr debug;
rewrite_log on;
proxy_set_header Host wechaty.github.io;
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_set_header Accept-Encoding $http_accept_encoding;
proxy_buffering off;
proxy_request_buffering off;
proxy_http_version 1.1;
proxy_intercept_errors on;
server {
listen 80;
#
# Docusaurus: match well-known locations
#
location ~ ^/(docs|press|qrcode|search|img|css|js) {
rewrite ^(.*)$ /docusaurus$1 break;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 301 302 307 = @handle_redirects;
proxy_pass https://wechaty.github.io;
}
#
# Jekyll: @jekyll will fail back to @jekyll_to_docusaurus when 404
#
location @jekyll {
rewrite ^(.*)$ /jekyll$1 break;
# https://stackoverflow.com/a/38010622/1123955
proxy_intercept_errors on;
recursive_error_pages on;
error_page 404 = @jekyll_to_docusaurus;
error_page 301 302 307 = @handle_redirects;
proxy_pass https://wechaty.github.io;
}
#
# How to follow HTTP redirects inside nginx?
# @link https://serverfault.com/a/792035/276381
#
location @handle_redirects {
set $orig_loc $upstream_http_location;
proxy_pass $orig_loc;
}
location @jekyll_to_docusaurus {
rewrite ^/jekyll(.*)$ /docusaurus$1 break;
proxy_intercept_errors on;
recursive_error_pages on;
error_page 301 302 307 = @handle_redirects;
proxy_pass https://wechaty.github.io;
}
#
# Default to @jekyll (then @docusaurus when 404)
#
# @jekyll will fail back to @docusaurus automatically when 404
# See `location @jekyll` above
location / {
try_files $uri @jekyll;
}
}
}