-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnginx.conf
251 lines (226 loc) · 7.12 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
server {
return 403;
}
map $http_origin $status_cors_host {
default 0;
"~https://mirrors.pku.edu.cn" https://mirrors.pku.edu.cn;
"~http://mirrors.pku.edu.cn" http://mirrors.pku.edu.cn;
"~https://mirrorz.org" https://mirrorz.org;
}
server {
listen 80 default;
listen [::]:80 default;
listen 443 ssl default;
listen [::]:443 ssl default;
server_name mirrors.pku.edu.cn;
deny 220.177.83.115;
# return 301 https://$server_name$request_uri;
error_log /var/log/nginx/repos_test_error.log;
access_log /var/log/nginx/repos_test_access.log;
root /data/repos/;
# XXX: Is it better to put those into /repos?
location /static/ {
location /static/help/ {
alias /data/web/help/;
gzip_static on;
}
location /static/ {
root /data/web/dist/;
gzip_static on;
}
}
location /repoconfig/ {
root /data/web/;
}
# proxy_cache_path /data/repos/npm/cache levels=1:2 keys_zone=npmcache:100m inactive=24h max_size=100g use_temp_path=off;
location /npm/ {
allow 162.105.0.0/16;
allow 2001:DA8:201::/48;
allow 240C:C001::/32;
deny all;
proxy_pass https://registry.npmjs.org/;
proxy_set_header Accept-Encoding "";
proxy_set_header Host registry.npmjs.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache npmcache;
proxy_cache_valid any 1d;
proxy_buffering on;
proxy_ignore_headers Expires;
proxy_ignore_headers X-Accel-Expires;
proxy_ignore_headers Cache-Control;
proxy_ignore_headers Set-Cookie;
proxy_hide_header X-Accel-Expires;
proxy_hide_header Expires;
proxy_hide_header Cache-Control;
proxy_hide_header Pragma;
sub_filter_types *;
sub_filter https://registry.npmjs.org/ $scheme://$host/npm/;
sub_filter_once off;
}
location /npm {
allow 162.105.0.0/16;
allow 2001:DA8:201::/48;
allow 240C:C001::/32;
deny all;
proxy_pass https://registry.npmjs.org/;
proxy_set_header Accept-Encoding "";
proxy_set_header Host registry.npmjs.org;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /repository1/ {
allow 162.105.0.0/16;
allow 2001:DA8:201::/48;
allow 240C:C001::/32;
deny all;
proxy_pass http://172.31.1.202:8081/repository/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /repository/ {
allow 162.105.0.0/16;
allow 2001:DA8:201::/48;
allow 240C:C001::/32;
deny all;
proxy_pass http://162.105.120.103:8081/repository/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /spring/ {
allow 162.105.0.0/16;
allow 2001:DA8:201::/48;
allow 240C:C001::/32;
deny all;
proxy_pass https://start.spring.io/;
proxy_set_header Host start.spring.io;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~ /monitor/(start|stop|log) {
try_files @error @error;
}
location /monitor/ {
proxy_pass http://localhost:3030/;
add_header Access-Control-Allow-Origin $status_cors_host;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
}
location /files/ {
proxy_pass http://localhost:3001/;
}
location = /robots.txt {
root /data/web/repoconfig/;
}
location = /google53f21eaac539b6a8.html {
root /data/web/repoconfig/;
}
location = /baidu_verify_code-E12Mj7SzYn.html {
root /data/web/repoconfig/;
}
# We will close this proxy during critical period
#location /monitor_device/ {
# location /monitor_device/api/ {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_pass http://127.0.0.1:19999/api/;
# add_header Access-Control-Allow-Origin $status_cors_host;
# add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
# add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
# }
# location /monitor_device/ {
# root /data/monitor/data/;
# error_page 404 /index.html;
# return 404;
# }
# }
location /monitor_device_status/ {
alias /data/monitor/data/;
}
location ~ /git-repos(/.+) {
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_param SCRIPT_FILENAME /usr/libexec/git-core/git-http-backend;
fastcgi_param GIT_HTTP_EXPORT_ALL "";
fastcgi_param GIT_PROJECT_ROOT /data/repos/git-repos;
fastcgi_param PATH_INFO $1;
fastcgi_param REMOTE_USER $remote_user;
include fastcgi_params;
}
# Web router
location = /index.html {
root /data/web/dist;
}
location = /Mirrors {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location /Mirrors/ {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location = /Status {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location /Status/ {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location = /Help {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location /Help/ {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location = /About {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location /About/ {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location = /Error404 {
root /data/web/dist/;
error_page 404 /index.html;
return 404;
}
location = / {
root /data/web/dist/;
rewrite ^ /index.html break;
}
location /pypi/ {
alias /data/repos/pypi/web/;
if (!-e $request_filename) {
root /data/web/dist/;
error_page 404 /index.html;
return 404;
}
try_files $uri $uri/index.html @frontend;
}
location / {
if (!-e $request_filename) {
root /data/web/dist/;
error_page 404 /index.html;
return 404;
}
try_files $uri @frontend;
}
location @error {
root /data/web/dist/;
error_page 404 /index.html;
return 404;
}
location @frontend {
root /data/web/dist;
rewrite ^ /index.html break;
}
# Managed by Certbot
ssl_certificate /etc/letsencrypt/live/mirrors.pku.edu.cn/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mirrors.pku.edu.cn/privkey.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
}