forked from cisagov/Malcolm
-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathnginx.conf
355 lines (306 loc) · 10.4 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
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# Copyright (c) 2025 Battelle Energy Alliance, LLC. All rights reserved.
daemon off;
worker_processes 1;
events { worker_connections 1024; }
http {
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/mime.types;
sendfile on;
client_max_body_size 20m;
client_body_buffer_size 128k;
client_header_buffer_size 256k;
large_client_header_buffers 8 256k;
fastcgi_buffers 16 64k;
fastcgi_buffer_size 256k;
fastcgi_read_timeout 300s;
fastcgi_busy_buffers_size 384k;
fastcgi_request_buffering off;
proxy_connect_timeout 180s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffer_size 512k;
proxy_buffers 16 4m;
proxy_busy_buffers_size 16m;
# if LDAP authentication is enabled, this will configure the ldap_server section
include /etc/nginx/nginx_ldap_rt.conf;
upstream arkime {
server arkime:8005;
}
upstream api {
server api:5000;
}
upstream upload {
server upload:80;
}
upstream htadmin {
server htadmin:80;
}
upstream dashboards {
server dashboards:5601;
}
upstream dashboards-maps {
server dashboards-helper:28991;
}
upstream opensearch {
server opensearch:9200;
}
upstream logstash-stats {
server logstash:9600;
}
upstream netbox {
server netbox:8080;
}
upstream extracted-file-http-server {
server file-monitor:8440;
}
# health check ("here I am") without authentication
server {
listen 8443;
include /etc/nginx/nginx_ssl_config.conf;
location / {
add_header Content-Type text/plain;
return 200 'Malcolm\n';
}
}
# Main web interface
server {
listen 443;
include /etc/nginx/nginx_ssl_config.conf;
# favicon, logos, banners, etc.
include /etc/nginx/nginx_image_aliases.conf;
# HTTP basic user management (doesn't use nginx_auth_rt as it does its own auth directly)
location /auth {
proxy_pass http://htadmin;
proxy_redirect off;
proxy_set_header Accept-Encoding "";
proxy_set_header Host htadmin.malcolm.local;
rewrite ^/auth/?(.*) /$1 break;
subs_filter_types '*';
subs_filter '(src|action|href)="([\w\.-]+\.(php|css|js))' '$1="/auth/$2' gir;
subs_filter 'href="styles/' 'href="/auth/styles/' gi;
subs_filter 'src="script/' 'src="/auth/script/' gi;
subs_filter '/fonts/glyphicons' '/auth/fonts/glyphicons' gi;
}
location ~* ^/(htadmin|admin_login)(\.php)\b(.*) {
proxy_pass http://htadmin/$1$2$3;
proxy_redirect off;
proxy_set_header Accept-Encoding "";
proxy_set_header Host htadmin.malcolm.local;
subs_filter_types '*';
subs_filter '(src|action|href)="([\w\.-]+\.(php|css|js))' '$1="/auth/$2' gir;
subs_filter 'href="styles/' 'href="/auth/styles/' gi;
subs_filter 'src="script/' 'src="/auth/script/' gi;
subs_filter '/fonts/glyphicons' '/auth/fonts/glyphicons' gi;
}
# Malcolm file upload
location /upload {
include /etc/nginx/nginx_auth_rt.conf;
proxy_http_version 1.1;
proxy_set_header Connection "";
rewrite ^/upload(.*)/?$ /$1 break;
proxy_pass http://upload;
proxy_redirect off;
proxy_set_header Host upload.malcolm.local;
proxy_request_buffering off;
proxy_buffering off;
client_max_body_size 50G;
}
location /server/php {
include /etc/nginx/nginx_auth_rt.conf;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://upload/server/php;
proxy_redirect off;
proxy_set_header Host upload.malcolm.local;
proxy_request_buffering off;
proxy_buffering off;
client_max_body_size 50G;
}
# netbox
location /netbox {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass http://netbox;
proxy_redirect off;
proxy_set_header Host netbox.malcolm.local;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Remote-Auth $authenticated_user;
}
# netbox from dashboards pivot link (because Dashboards is prepending its own prefix, we have to handle it)
location ~* ^/dashboards/app/netbox/(.*) {
set $forwarded_scheme $scheme;
if ($http_x_forwarded_proto = 'https') {
set $forwarded_scheme https;
}
set $fwuri $1;
rewrite ^/dashboards/app/netbox/(.*) $forwarded_scheme://$host/netbox/$1 redirect;
proxy_pass http://netbox;
proxy_redirect off;
proxy_set_header Host netbox.malcolm.local;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Remote-Auth $authenticated_user;
}
# extracted file download
location ~* ^/extracted-files\b(.*) {
include /etc/nginx/nginx_auth_rt.conf;
# thanks to https://stackoverflow.com/a/31440150, handle spaces in names
set $filereq $1;
proxy_pass http://extracted-file-http-server$filereq$is_args$args;
proxy_redirect off;
proxy_set_header Host file-monitor.malcolm.local;
}
# extracted files from dashboards link (because Dashboards is prepending its own prefix, we have to handle it)
location ~* ^/dashboards/app/extracted-files/(.*) {
set $forwarded_scheme $scheme;
if ($http_x_forwarded_proto = 'https') {
set $forwarded_scheme https;
}
set $fwuri $1;
rewrite ^/dashboards/app/extracted-files/(.*) $forwarded_scheme://$host/extracted-files/$1 redirect;
proxy_pass http://extracted-file-http-server;
proxy_redirect off;
proxy_set_header Host file-monitor.malcolm.local;
}
# extracted file download hedgehog redirect
location ~* ^/(dashboards/app/)?hh-extracted-files/([a-zA-Z0-9-\.]+)\b(.*) {
include /etc/nginx/nginx_auth_rt.conf;
include /etc/nginx/nginx_system_resolver.conf;
set $upstream $2:8006;
set $filereq $3;
rewrite ^/(dashboards/app/)?hh-extracted-files/([a-zA-Z0-9-\.]+)(.*)$ $filereq break;
proxy_pass https://$upstream;
proxy_ssl_verify off;
proxy_set_header Host $2;
proxy_set_header X-Malcolm-Forward "/hh-extracted-files/$2";
}
# Arkime -> Dashboards shortcut
location ~* /idark2dash(.*) {
set $filter_start_time now-1d;
if ($arg_start != '') {
set $filter_start_time \'$arg_start\';
}
set $filter_stop_time now;
if ($arg_stop != '') {
set $filter_stop_time \'$arg_stop\';
}
set $filter_field undefined;
if ($arg_field != '') {
set $filter_field $arg_field;
}
set $filter_value undefined;
if ($arg_value != '') {
set $filter_value $arg_value;
}
include /etc/nginx/nginx_idark2dash_rewrite_rt.conf;
}
# Dashboards -> Arkime shortcut
location ~* /iddash2ark/(.*) {
set $forwarded_scheme $scheme;
if ($http_x_forwarded_proto = 'https') {
set $forwarded_scheme https;
}
rewrite ^.*/iddash2ark/(.*) $forwarded_scheme://$host/arkime/sessions?expression=($1) redirect;
proxy_pass https://arkime;
proxy_ssl_verify off;
proxy_redirect off;
proxy_set_header Host arkime.malcolm.local;
proxy_set_header http_auth_http_user $authenticated_user;
proxy_set_header Authorization "";
}
# OpenSearch dashboards (or Kibana)
location /dashboards {
include /etc/nginx/nginx_dashboards_rewrite_rt.conf;
}
# offline region maps for dashboards
location /world.geojson {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass http://dashboards-maps;
proxy_redirect off;
proxy_set_header Host dashboards-helper.malcolm.local;
}
# Fix cyberchef JS module(s)
# https://localhost/arkime/session/190924-KgO9H30qhdREw7ltsDXn1Rgp/modules/Regex.js
location ~* ^/arkime/session/.*/(modules/.*\.js) {
include /etc/nginx/nginx_auth_rt.conf;
proxy_hide_header Content-Type;
proxy_set_header Content-Type "application/javascript";
add_header Content-Type "application/javascript";
default_type application/javascript;
add_header X-Content-Type-Options 'nosniff';
proxy_pass https://arkime/cyberchef/$1;
proxy_ssl_verify off;
proxy_redirect off;
proxy_set_header Host arkime.malcolm.local;
proxy_set_header http_auth_http_user $authenticated_user;
proxy_set_header Authorization "";
}
# passthrough Logstash statistics from the Malcolm API
location /mapi/logstash/ {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass http://logstash-stats/;
proxy_redirect off;
}
# passthrough OpenSearch from the Malcolm API
location /mapi/opensearch/ {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass http://opensearch/;
proxy_redirect off;
proxy_set_header Host os.malcolm.local;
client_max_body_size 50m;
}
# passthrough NetBox from the Malcolm API
location /mapi/netbox/ {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass http://netbox/netbox/api/;
proxy_redirect off;
proxy_set_header Host netbox.malcolm.local;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Remote-Auth $authenticated_user;
}
# Malcolm API
location /mapi {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass http://api;
proxy_redirect off;
proxy_set_header Host api.malcolm.local;
}
# Arkime
location /arkime {
include /etc/nginx/nginx_auth_rt.conf;
proxy_pass https://arkime;
proxy_redirect off;
proxy_set_header Host arkime.malcolm.local;
proxy_set_header http_auth_http_user $authenticated_user;
proxy_set_header Authorization "";
}
# Landing Page and README
location / {
include /etc/nginx/nginx_auth_rt.conf;
root /usr/share/nginx/html;
index index.html
try_files $uri $uri/ =404;
error_page 404 /404.html;
error_page 502 /502.html;
}
}
# OpenSearch API
server {
listen 9200;
include /etc/nginx/nginx_ssl_config.conf;
# use either auth_basic or auth_ldap
include /etc/nginx/nginx_auth_rt.conf;
# favicon, logos, banners, etc.
include /etc/nginx/nginx_image_aliases.conf;
location / {
proxy_pass http://opensearch;
proxy_redirect off;
proxy_set_header Host os.malcolm.local;
client_max_body_size 50m;
}
}
}