-
Notifications
You must be signed in to change notification settings - Fork 16
/
doaj
284 lines (254 loc) · 10.3 KB
/
doaj
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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
# Metrics for metricsbeat
server {
listen [::]:80;
listen 80;
server_name 127.0.0.1;
location /server-status {
stub_status on;
access_log off;
allow ::1;
allow 127.0.0.1;
deny all;
}
}
log_format ip_cloudflare '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" "$http_user_agent" '
'$http_cf_connecting_ip';
#ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!3DES:!MD5:!PSK';
#ssl_ciphers 'HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES';
#ssl_stapling on;
# NOTE: change back to $binary_remote_addr if the app is no longer being served through cloudflare.
limit_req_zone $http_cf_connecting_ip zone=general:100m rate=8r/s;
limit_req_zone $http_cf_connecting_ip zone=api:100m rate=12r/s;
limit_req_status 429;
map $http_user_agent $block_ua {
default 0;
~*bot 1;
~*spider 1;
~*Go-http-client 1;
~*python-requests 1;
~*mechanize 1;
~*wget 1;
~*curl 1;
}
upstream doaj_apps {
server 10.131.191.139:5050;
}
upstream doaj_bg_apps {
#server 10.131.56.133:5050; #old bg machine
server 10.131.12.33:5050;
}
upstream doaj_apps_failover {
server 10.131.191.139:5050;
#server 10.131.56.133:5050 backup; #old bg machine
server 10.131.12.33:5050 backup;
}
upstream doaj_index {
server 10.131.191.132:9200;
server 10.131.191.133:9200;
}
# Redirect map for legacy page routes https://github.com/DOAJ/doajPM/issues/2398
map $request_uri $new_uri {
include /etc/nginx/doaj-redirects.map;
}
# redirect to SSL version but serve some crucial xml schemas via plain http as well
server {
listen 80;
server_name .doaj.org doajes.cottagelabs.com;
access_log /var/log/nginx/doaj.access.log ip_cloudflare;
error_log /var/log/nginx/doaj.error.log;
location =/static/doaj/doajArticle.xsd {
alias /home/cloo/doaj/src/doaj/portality/static/doaj/doajArticles.xsd;
}
location =/static/doaj/doajArticles.xsd {
alias /home/cloo/doaj/src/doaj/portality/static/doaj/doajArticles.xsd;
}
location =/static/doaj/iso_639-2b.xsd {
alias /home/cloo/doaj/src/doaj/portality/static/doaj/iso_639-2b.xsd;
}
location /static/crossref {
alias /home/cloo/doaj/src/doaj/portality/static/crossref;
}
location =/robots.txt {
alias /home/cloo/doaj/src/doaj/deploy/robots-production.txt;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name doaj.org;
ssl_certificate /etc/letsencrypt/live/doaj.org/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/doaj.org/privkey.pem;
proxy_read_timeout 600s;
client_max_body_size 50M;
access_log /var/log/nginx/doaj.access.log ip_cloudflare;
error_log /var/log/nginx/doaj.error.log;
if ($new_uri != "") {
rewrite ^(.*)$ $new_uri permanent;
}
location /api {
if ($http_user_agent ~* (bot|spider) ) {
return 403;
}
limit_req zone=api burst=8 nodelay;
proxy_pass http://doaj_apps_failover;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /search {
if ($block_ua) {return 403;}
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_apps_failover;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /query {
if ($block_ua) {return 403;}
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_apps_failover;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
# for now we are going to send all login functions to the bg machine
# technically ONLY the routes that require file upload need to go to the bg machine
# but we think it is handy to separate them out, and later we could send them to other machines
location /account {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /admin { # there are admin bulk actions that MUST go to bg machine
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /editor {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /journal/readonly {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /publisher { # only /publisher/uploadfile MUST go to bg, and /publisher/uploadFile
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /service {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
# eventually we want to switch these so that they are served from disk, but
# that requires code changes in the app. For now, they are generated by the
# code in a background task, so they have to be served by the app on the bg server
location /sitemap.xml {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location /csv {
limit_req zone=general burst=10 nodelay;
proxy_pass http://doaj_bg_apps;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
location =/robots.txt {
alias /home/cloo/doaj/src/doaj/deploy/robots-production.txt;
}
location /static/ {
alias /home/cloo/doaj/src/doaj/portality/static/;
autoindex off;
expires max;
add_header 'Access-Control-Allow-Origin' '*'; # CORS settings since we don't get these from the app
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
location /assets/ {
alias /home/cloo/doaj/src/doaj/cms/assets/;
autoindex off;
expires max;
add_header 'Access-Control-Allow-Origin' '*'; # CORS settings since we don't get these from the app
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
}
location / {
limit_req zone=general burst=20 nodelay;
proxy_pass http://doaj_apps_failover;
proxy_redirect off;
proxy_set_header Host $host;
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_buffering off;
}
}
server {
listen 443;
server_name doajes.cottagelabs.com;
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
location / {
proxy_pass http://doaj_index;
}
ssl_certificate /etc/letsencrypt/live/doajes.cottagelabs.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/doajes.cottagelabs.com/privkey.pem;
}