securenow 5.10.2 → 5.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,697 +1,880 @@
1
- # SecureNow Environment Variables Reference
2
-
3
- Complete reference for all environment variables supported by SecureNow.
4
-
5
- ---
6
-
7
- ## Quick Reference Table
8
-
9
- | Variable | Type | Default | Description |
10
- |----------|------|---------|-------------|
11
- | **SECURENOW_APPID** | Required | - | Application identifier / service name |
12
- | **SECURENOW_INSTANCE** | Required | `https://freetrial.securenow.ai:4318` | OTLP collector base URL |
13
- | **SECURENOW_LOGGING_ENABLED** | Optional | `1` | Enable/disable logging |
14
- | **SECURENOW_NO_UUID** | Optional | `0` | Disable UUID suffix on service name |
15
- | **SECURENOW_STRICT** | Optional | `0` | Exit if APPID missing in cluster mode |
16
- | **SECURENOW_CAPTURE_BODY** | Optional | `0` | Enable request body capture |
17
- | **SECURENOW_MAX_BODY_SIZE** | Optional | `10240` | Max body size in bytes |
18
- | **SECURENOW_SENSITIVE_FIELDS** | Optional | - | Comma-separated list of fields to redact |
19
- | **SECURENOW_CAPTURE_MULTIPART** | Optional | `0` | Enable multipart/form-data streaming capture |
20
- | **SECURENOW_DISABLE_INSTRUMENTATIONS** | Optional | - | Comma-separated list of packages to disable |
21
- | **SECURENOW_TEST_SPAN** | Optional | `0` | Emit test span on startup |
22
- | **OTEL_SERVICE_NAME** | Optional | - | Alternative to SECURENOW_APPID |
23
- | **OTEL_EXPORTER_OTLP_ENDPOINT** | Optional | - | Alternative to SECURENOW_INSTANCE |
24
- | **OTEL_EXPORTER_OTLP_HEADERS** | Optional | - | Headers for OTLP requests |
25
- | **OTEL_EXPORTER_OTLP_TRACES_ENDPOINT** | Optional | - | Override traces endpoint |
26
- | **OTEL_EXPORTER_OTLP_LOGS_ENDPOINT** | Optional | - | Override logs endpoint |
27
- | **OTEL_LOG_LEVEL** | Optional | `none` | SDK log level |
28
- | **NODE_ENV** | Optional | `production` | Environment name |
29
-
30
- ---
31
-
32
- ## Required Variables
33
-
34
- ### SECURENOW_APPID
35
-
36
- **Description:** Your application identifier. Used as the service name in traces and logs.
37
-
38
- **Format:** String (alphanumeric, hyphens, underscores)
39
-
40
- **Examples:**
41
- ```bash
42
- export SECURENOW_APPID=my-express-app
43
- export SECURENOW_APPID=api-gateway
44
- export SECURENOW_APPID=user-service
45
- ```
46
-
47
- **Notes:**
48
- - If not set, SecureNow will use a fallback name with UUID
49
- - In cluster mode with `SECURENOW_STRICT=1`, missing APPID will cause process exit
50
- - Alternative: Use `OTEL_SERVICE_NAME` (OpenTelemetry standard)
51
-
52
- **Behavior:**
53
- - Without `SECURENOW_NO_UUID=1`: Service name becomes `{APPID}-{UUID}`
54
- - With `SECURENOW_NO_UUID=1`: Service name is exactly `{APPID}`
55
-
56
- ---
57
-
58
- ### SECURENOW_INSTANCE
59
-
60
- **Description:** Base URL of your OTLP collector endpoint.
61
-
62
- **Format:** URL (http/https)
63
-
64
- **Examples:**
65
- ```bash
66
- # Local collector
67
- export SECURENOW_INSTANCE=http://localhost:4318
68
-
69
- # Remote collector
70
- export SECURENOW_INSTANCE=http://collector.example.com:4318
71
-
72
- # HTTPS
73
- export SECURENOW_INSTANCE=https://collector.example.com:4318
74
- ```
75
-
76
- **Default:** `https://freetrial.securenow.ai:4318` (if not set)
77
-
78
- **Notes:**
79
- - Used to construct traces and logs endpoints
80
- - Traces sent to: `{SECURENOW_INSTANCE}/v1/traces`
81
- - Logs sent to: `{SECURENOW_INSTANCE}/v1/logs`
82
- - Alternative: Use `OTEL_EXPORTER_OTLP_ENDPOINT`
83
-
84
- ---
85
-
86
- ## Service Naming
87
-
88
- ### OTEL_SERVICE_NAME
89
-
90
- **Description:** Standard OpenTelemetry variable for service name. Alternative to `SECURENOW_APPID`.
91
-
92
- **Format:** String
93
-
94
- **Example:**
95
- ```bash
96
- export OTEL_SERVICE_NAME=my-app
97
- ```
98
-
99
- **Priority:** If both are set, `OTEL_SERVICE_NAME` takes precedence.
100
-
101
- ---
102
-
103
- ### SECURENOW_NO_UUID
104
-
105
- **Description:** Disable automatic UUID suffix on service name.
106
-
107
- **Format:** `1` (enabled) or `0` (disabled)
108
-
109
- **Default:** `0`
110
-
111
- **Example:**
112
- ```bash
113
- export SECURENOW_NO_UUID=1
114
- ```
115
-
116
- **Use case:**
117
- - PM2 cluster mode - use same service name for all workers
118
- - Docker containers with replica sets
119
- - Kubernetes pods in a deployment
120
-
121
- **Behavior:**
122
- - `0`: Service name = `my-app-a1b2c3d4`
123
- - `1`: Service name = `my-app`
124
-
125
- ---
126
-
127
- ### SECURENOW_STRICT
128
-
129
- **Description:** Exit process if `SECURENOW_APPID` is not set in cluster mode.
130
-
131
- **Format:** `1` (enabled) or `0` (disabled)
132
-
133
- **Default:** `0`
134
-
135
- **Example:**
136
- ```bash
137
- export SECURENOW_STRICT=1
138
- ```
139
-
140
- **Use case:**
141
- - Production environments where service name must be explicit
142
- - Prevent "free" or auto-generated service names
143
- - Ensure proper configuration before starting
144
-
145
- **Detection:**
146
- Cluster mode is detected when any of these exist:
147
- - `NODE_APP_INSTANCE` (PM2)
148
- - `pm_id` (PM2)
149
-
150
- ---
151
-
152
- ## Connection Settings
153
-
154
- ### OTEL_EXPORTER_OTLP_ENDPOINT
155
-
156
- **Description:** Standard OpenTelemetry variable for OTLP endpoint. Alternative to `SECURENOW_INSTANCE`.
157
-
158
- **Format:** URL
159
-
160
- **Example:**
161
- ```bash
162
- export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
163
- ```
164
-
165
- **Priority:** If both are set, `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence.
166
-
167
- ---
168
-
169
- ### OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
170
-
171
- **Description:** Override the traces endpoint specifically.
172
-
173
- **Format:** Full URL including `/v1/traces`
174
-
175
- **Example:**
176
- ```bash
177
- export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
178
- ```
179
-
180
- **Use case:**
181
- - Separate collectors for traces and logs
182
- - Different routing for traces
183
-
184
- ---
185
-
186
- ### OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
187
-
188
- **Description:** Override the logs endpoint specifically.
189
-
190
- **Format:** Full URL including `/v1/logs`
191
-
192
- **Example:**
193
- ```bash
194
- export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
195
- ```
196
-
197
- **Use case:**
198
- - Separate collectors for traces and logs
199
- - Different routing for logs
200
-
201
- ---
202
-
203
- ### OTEL_EXPORTER_OTLP_HEADERS
204
-
205
- **Description:** Headers to include in OTLP export requests.
206
-
207
- **Format:** Comma-separated `key=value` pairs
208
-
209
- **Examples:**
210
- ```bash
211
- # Single header
212
- export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"
213
-
214
- # Multiple headers
215
- export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=key123,x-tenant-id=tenant456"
216
-
217
- # Authentication
218
- export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer token123"
219
- ```
220
-
221
- **Use case:**
222
- - API authentication
223
- - Multi-tenancy headers
224
- - Custom routing headers
225
-
226
- **Notes:**
227
- - Header names are case-insensitive
228
- - Trailing/leading spaces are trimmed
229
-
230
- ---
231
-
232
- ## Logging
233
-
234
- ### SECURENOW_LOGGING_ENABLED
235
-
236
- **Description:** Enable or disable automatic logging to OTLP backend.
237
-
238
- **Format:** `1` (enabled) or `0` (disabled)
239
-
240
- **Default:** `1` (enabled by default)
241
-
242
- **Examples:**
243
- ```bash
244
- # Enable logging
245
- export SECURENOW_LOGGING_ENABLED=1
246
-
247
- # Disable logging
248
- export SECURENOW_LOGGING_ENABLED=0
249
- ```
250
-
251
- **When enabled:**
252
- - Logs are sent to `{SECURENOW_INSTANCE}/v1/logs`
253
- - Console instrumentation can capture logs
254
- - Direct logger API is available
255
-
256
- **When disabled:**
257
- - No logs sent to backend
258
- - `getLogger()` returns `null`
259
- - Console instrumentation shows warning
260
-
261
- ---
262
-
263
- ## Request Body Capture
264
-
265
- ### SECURENOW_CAPTURE_BODY
266
-
267
- **Description:** Enable capture of HTTP request bodies in traces.
268
-
269
- **Format:** `1` (enabled) or `0` (disabled)
270
-
271
- **Default:** `0` (disabled)
272
-
273
- **Example:**
274
- ```bash
275
- export SECURENOW_CAPTURE_BODY=1
276
- ```
277
-
278
- **Supported content types:**
279
- - `application/json`
280
- - `application/x-www-form-urlencoded`
281
- - `application/graphql`
282
-
283
- **Not captured (unless separately enabled):**
284
- - `multipart/form-data` — requires `SECURENOW_CAPTURE_MULTIPART=1` (see below)
285
- - Bodies larger than `SECURENOW_MAX_BODY_SIZE`
286
-
287
- **Security:**
288
- All captured bodies are automatically scanned for sensitive fields and redacted.
289
-
290
- ---
291
-
292
- ### SECURENOW_MAX_BODY_SIZE
293
-
294
- **Description:** Maximum request body size to capture (in bytes).
295
-
296
- **Format:** Number (bytes)
297
-
298
- **Default:** `10240` (10 KB)
299
-
300
- **Examples:**
301
- ```bash
302
- # 10 KB (default)
303
- export SECURENOW_MAX_BODY_SIZE=10240
304
-
305
- # 20 KB
306
- export SECURENOW_MAX_BODY_SIZE=20480
307
-
308
- # 5 KB
309
- export SECURENOW_MAX_BODY_SIZE=5120
310
- ```
311
-
312
- **Behavior:**
313
- - Bodies larger than this are not captured
314
- - Span attribute shows: `[TOO LARGE: {size} bytes]`
315
-
316
- ---
317
-
318
- ### SECURENOW_SENSITIVE_FIELDS
319
-
320
- **Description:** Additional field names to redact from request bodies (comma-separated).
321
-
322
- **Format:** Comma-separated list of field names
323
-
324
- **Default:** (see below for auto-redacted fields)
325
-
326
- **Examples:**
327
- ```bash
328
- # Additional custom fields
329
- export SECURENOW_SENSITIVE_FIELDS="internal_token,session_key"
330
-
331
- # Multiple fields
332
- export SECURENOW_SENSITIVE_FIELDS="custom_secret,private_data,internal_id"
333
- ```
334
-
335
- **Auto-redacted fields (built-in):**
336
- - `password`, `passwd`, `pwd`
337
- - `secret`, `token`, `api_key`, `apikey`, `access_token`
338
- - `auth`, `credentials`, `mysql_pwd`
339
- - `stripeToken`, `card`, `cardnumber`
340
- - `ccv`, `cvc`, `cvv`
341
- - `ssn`, `pin`
342
-
343
- **Matching:**
344
- - Case-insensitive
345
- - Substring match (e.g., `password` matches `user_password`, `PASSWORD`, `passwordField`)
346
- - Works recursively in nested objects
347
-
348
- ---
349
-
350
- ### SECURENOW_CAPTURE_MULTIPART
351
-
352
- **Description:** Enable capture of `multipart/form-data` request bodies (file upload metadata and text fields). Uses a streaming parser that processes boundary markers on the fly — file binary content is never buffered or stored.
353
-
354
- **Format:** `1` (enabled) or `0` (disabled)
355
-
356
- **Default:** `0` (disabled)
357
-
358
- **Example:**
359
- ```bash
360
- export SECURENOW_CAPTURE_MULTIPART=1
361
- ```
362
-
363
- **What gets captured:**
364
- - **Text fields** — field name and value (up to 1000 characters), with sensitive fields auto-redacted
365
- - **File fields** metadata only: field name, filename, content-type, and size in bytes (no binary content)
366
-
367
- **Example span attribute (`http.request.body`):**
368
- ```json
369
- {
370
- "fields": { "description": "My upload", "token": "[REDACTED]" },
371
- "files": [
372
- { "field": "avatar", "filename": "photo.jpg", "contentType": "image/jpeg", "size": 524288 },
373
- { "field": "document", "filename": "report.pdf", "contentType": "application/pdf", "size": 1048576 }
374
- ]
375
- }
376
- ```
377
-
378
- **Additional span attributes set:**
379
- - `http.request.body.type` = `"multipart"`
380
- - `http.request.body.size` — total raw request body size in bytes
381
- - `http.request.body.fields_count` number of text fields
382
- - `http.request.body.files_count` — number of file fields
383
-
384
- **Memory:** Bounded at ~few KB regardless of upload size (streaming parser discards file content as it passes through).
385
-
386
- **Parts limit:** 100 parts maximum per request (safety guard).
387
-
388
- **Requires:** `SECURENOW_CAPTURE_BODY=1` must also be set (multipart capture is gated behind general body capture).
389
-
390
- **Since:** v5.8.0
391
-
392
- ---
393
-
394
- ## Instrumentation Control
395
-
396
- ### SECURENOW_DISABLE_INSTRUMENTATIONS
397
-
398
- **Description:** Disable specific OpenTelemetry instrumentations.
399
-
400
- **Format:** Comma-separated list of package names
401
-
402
- **Example:**
403
- ```bash
404
- # Disable file system and DNS instrumentations
405
- export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
406
-
407
- # Disable multiple
408
- export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net,http2
409
- ```
410
-
411
- **Common packages you might disable:**
412
- - `fs` - File system operations
413
- - `dns` - DNS lookups
414
- - `net` - Network operations
415
- - `http2` - HTTP/2 client/server
416
- - `grpc` - gRPC client/server
417
-
418
- **Use case:**
419
- - Reduce overhead by disabling unused instrumentations
420
- - Avoid noisy traces from certain operations
421
- - Debug issues with specific instrumentations
422
-
423
- ---
424
-
425
- ## Debugging
426
-
427
- ### OTEL_LOG_LEVEL
428
-
429
- **Description:** OpenTelemetry SDK internal log level.
430
-
431
- **Format:** `none`, `error`, `warn`, `info`, `debug`
432
-
433
- **Default:** `none`
434
-
435
- **Examples:**
436
- ```bash
437
- # See all debug information
438
- export OTEL_LOG_LEVEL=debug
439
-
440
- # Only errors
441
- export OTEL_LOG_LEVEL=error
442
-
443
- # No SDK logs
444
- export OTEL_LOG_LEVEL=none
445
- ```
446
-
447
- **Use case:**
448
- - Troubleshooting setup issues
449
- - Understanding trace/log export behavior
450
- - Debugging connection problems
451
-
452
- **Output:**
453
- - Goes to console (stderr)
454
- - Prefixed with `[securenow]`
455
-
456
- ---
457
-
458
- ### SECURENOW_TEST_SPAN
459
-
460
- **Description:** Emit a test span on startup to verify tracing is working.
461
-
462
- **Format:** `1` (enabled) or `0` (disabled)
463
-
464
- **Default:** `0`
465
-
466
- **Example:**
467
- ```bash
468
- export SECURENOW_TEST_SPAN=1
469
- ```
470
-
471
- **Behavior:**
472
- - Creates a span named `securenow.startup.smoke`
473
- - Span is immediately ended
474
- - Useful for testing collector connectivity
475
-
476
- ---
477
-
478
- ## Environment
479
-
480
- ### NODE_ENV
481
-
482
- **Description:** Standard Node.js environment variable. Sent as `deployment.environment` attribute.
483
-
484
- **Format:** String (typically: `development`, `production`, `test`, `staging`)
485
-
486
- **Default:** `production`
487
-
488
- **Examples:**
489
- ```bash
490
- export NODE_ENV=development
491
- export NODE_ENV=production
492
- export NODE_ENV=staging
493
- export NODE_ENV=test
494
- ```
495
-
496
- **Use case:**
497
- - Filter traces/logs by environment
498
- - Different configurations per environment
499
- - Standard Node.js convention
500
-
501
- ---
502
-
503
- ## Configuration Examples
504
-
505
- ### Development Environment
506
-
507
- ```bash
508
- # .env.development
509
- SECURENOW_APPID=my-app-dev
510
- SECURENOW_INSTANCE=http://localhost:4318
511
- SECURENOW_LOGGING_ENABLED=1
512
- SECURENOW_CAPTURE_BODY=1
513
- SECURENOW_MAX_BODY_SIZE=20480
514
- OTEL_LOG_LEVEL=debug
515
- SECURENOW_TEST_SPAN=1
516
- NODE_ENV=development
517
- ```
518
-
519
- ### Production Environment
520
-
521
- ```bash
522
- # .env.production
523
- SECURENOW_APPID=my-app-prod
524
- SECURENOW_INSTANCE=https://collector.prod.example.com:4318
525
- OTEL_EXPORTER_OTLP_HEADERS=x-api-key=prod-key-12345
526
- SECURENOW_LOGGING_ENABLED=1
527
- SECURENOW_CAPTURE_BODY=0
528
- SECURENOW_NO_UUID=1
529
- SECURENOW_STRICT=1
530
- SECURENOW_SENSITIVE_FIELDS=internal_id,session_token
531
- OTEL_LOG_LEVEL=error
532
- NODE_ENV=production
533
- ```
534
-
535
- ### PM2 Cluster
536
-
537
- ```bash
538
- # ecosystem.config.js environment
539
- SECURENOW_APPID=my-app
540
- SECURENOW_INSTANCE=http://localhost:4318
541
- SECURENOW_LOGGING_ENABLED=1
542
- SECURENOW_NO_UUID=1
543
- SECURENOW_STRICT=1
544
- SECURENOW_CAPTURE_BODY=1
545
- NODE_ENV=production
546
- ```
547
-
548
- ### Docker / Kubernetes
549
-
550
- ```bash
551
- # Docker environment or K8s ConfigMap
552
- SECURENOW_APPID=my-service
553
- SECURENOW_INSTANCE=http://otel-collector:4318
554
- SECURENOW_LOGGING_ENABLED=1
555
- SECURENOW_NO_UUID=1
556
- SECURENOW_CAPTURE_BODY=0
557
- NODE_ENV=production
558
- ```
559
-
560
- ### Separate Collectors for Traces and Logs
561
-
562
- ```bash
563
- # Different backends for traces and logs
564
- SECURENOW_APPID=my-app
565
- OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
566
- OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
567
- SECURENOW_LOGGING_ENABLED=1
568
- ```
569
-
570
- ---
571
-
572
- ## Priority and Overrides
573
-
574
- When multiple variables are set, this is the priority order:
575
-
576
- ### Service Name
577
-
578
- 1. `OTEL_SERVICE_NAME` (highest priority)
579
- 2. `SECURENOW_APPID`
580
- 3. Auto-generated fallback (lowest priority)
581
-
582
- ### OTLP Endpoint
583
-
584
- 1. `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (for traces)
585
- 2. `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (for logs)
586
- 3. `OTEL_EXPORTER_OTLP_ENDPOINT`
587
- 4. `SECURENOW_INSTANCE`
588
- 5. Default: `https://freetrial.securenow.ai:4318` (lowest priority)
589
-
590
- ---
591
-
592
- ## Validation
593
-
594
- SecureNow validates environment variables on startup. Check console output:
595
-
596
- ```bash
597
- [securenow] pid=12345 SECURENOW_APPID="my-app" OTEL_SERVICE_NAME=null → service.name=my-app-uuid123
598
- [securenow] OTel SDK started → http://localhost:4318/v1/traces
599
- [securenow] 📋 Logging: ENABLED http://localhost:4318/v1/logs
600
- [securenow] 📝 Request body capture: ENABLED (max: 10240 bytes)
601
- ```
602
-
603
- ---
604
-
605
- ## Best Practices
606
-
607
- ### 1. Use .env Files
608
-
609
- Don't hardcode in your application:
610
-
611
- ```bash
612
- # .env
613
- SECURENOW_APPID=my-app
614
- SECURENOW_INSTANCE=http://localhost:4318
615
- ```
616
-
617
- ### 2. Different Configs per Environment
618
-
619
- ```bash
620
- # .env.development
621
- SECURENOW_CAPTURE_BODY=1
622
- OTEL_LOG_LEVEL=debug
623
-
624
- # .env.production
625
- SECURENOW_CAPTURE_BODY=0
626
- OTEL_LOG_LEVEL=error
627
- ```
628
-
629
- ### 3. Use SECURENOW_NO_UUID in Clusters
630
-
631
- ```bash
632
- # PM2 cluster with 4 workers
633
- SECURENOW_NO_UUID=1
634
- ```
635
-
636
- ### 4. Enable SECURENOW_STRICT in Production
637
-
638
- ```bash
639
- # Fail fast if misconfigured
640
- SECURENOW_STRICT=1
641
- ```
642
-
643
- ### 5. Disable Body Capture in Production
644
-
645
- ```bash
646
- # Development
647
- SECURENOW_CAPTURE_BODY=1
648
-
649
- # Production
650
- SECURENOW_CAPTURE_BODY=0
651
- ```
652
-
653
- ---
654
-
655
- ## Troubleshooting
656
-
657
- ### Check Current Values
658
-
659
- ```bash
660
- # Print all SECURENOW variables
661
- env | grep SECURENOW
662
-
663
- # Print all OTEL variables
664
- env | grep OTEL
665
-
666
- # Check specific variable
667
- echo $SECURENOW_APPID
668
- ```
669
-
670
- ### Verify in Application
671
-
672
- SecureNow logs current configuration on startup. Look for lines like:
673
-
674
- ```
675
- [securenow] pid=12345 SECURENOW_APPID="my-app" → service.name=my-app
676
- [securenow] OTel SDK started → http://localhost:4318/v1/traces
677
- ```
678
-
679
- ### Enable Debug Mode
680
-
681
- ```bash
682
- export OTEL_LOG_LEVEL=debug
683
- node app.js
684
- ```
685
-
686
- ---
687
-
688
- ## Related Documentation
689
-
690
- - [Express Setup Guide](./EXPRESS-SETUP-GUIDE.md)
691
- - [Next.js Setup Guide](./NEXTJS-SETUP-COMPLETE.md)
692
- - [Logging Guide](./LOGGING-GUIDE.md)
693
- - [NPM README](../NPM_README.md)
694
-
695
- ---
696
-
697
- **Complete reference for all SecureNow environment variables.** 🎯
1
+ # SecureNow Environment Variables Reference
2
+
3
+ Complete reference for all environment variables supported by SecureNow.
4
+
5
+ ---
6
+
7
+ ## Quick Reference Table
8
+
9
+ | Variable | Type | Default | Description |
10
+ |----------|------|---------|-------------|
11
+ | **SECURENOW_APPID** | Required | - | Application identifier / service name |
12
+ | **SECURENOW_INSTANCE** | Required | `https://freetrial.securenow.ai:4318` | OTLP collector base URL |
13
+ | **SECURENOW_LOGGING_ENABLED** | Optional | `1` | Enable/disable logging |
14
+ | **SECURENOW_NO_UUID** | Optional | `0` | Disable UUID suffix on service name |
15
+ | **SECURENOW_STRICT** | Optional | `0` | Exit if APPID missing in cluster mode |
16
+ | **SECURENOW_CAPTURE_BODY** | Optional | `0` | Enable request body capture |
17
+ | **SECURENOW_MAX_BODY_SIZE** | Optional | `10240` | Max body size in bytes |
18
+ | **SECURENOW_SENSITIVE_FIELDS** | Optional | - | Comma-separated list of fields to redact |
19
+ | **SECURENOW_CAPTURE_MULTIPART** | Optional | `0` | Enable multipart/form-data streaming capture |
20
+ | **SECURENOW_DISABLE_INSTRUMENTATIONS** | Optional | - | Comma-separated list of packages to disable |
21
+ | **SECURENOW_TEST_SPAN** | Optional | `0` | Emit test span on startup |
22
+ | **OTEL_SERVICE_NAME** | Optional | - | Alternative to SECURENOW_APPID |
23
+ | **OTEL_EXPORTER_OTLP_ENDPOINT** | Optional | - | Alternative to SECURENOW_INSTANCE |
24
+ | **OTEL_EXPORTER_OTLP_HEADERS** | Optional | - | Headers for OTLP requests |
25
+ | **OTEL_EXPORTER_OTLP_TRACES_ENDPOINT** | Optional | - | Override traces endpoint |
26
+ | **OTEL_EXPORTER_OTLP_LOGS_ENDPOINT** | Optional | - | Override logs endpoint |
27
+ | **OTEL_LOG_LEVEL** | Optional | `none` | SDK log level |
28
+ | **NODE_ENV** | Optional | `production` | Environment name |
29
+ | **SECURENOW_API_KEY** | Optional | - | API key for firewall (auto-activates when set) |
30
+ | **SECURENOW_API_URL** | Optional | `https://api.securenow.ai` | API base URL |
31
+ | **SECURENOW_FIREWALL_ENABLED** | Optional | `1` | Firewall master kill-switch |
32
+ | **SECURENOW_FIREWALL_SYNC_INTERVAL** | Optional | `60` | Blocklist refresh interval (seconds) |
33
+ | **SECURENOW_FIREWALL_FAIL_MODE** | Optional | `open` | Behavior when API unreachable: open/closed |
34
+ | **SECURENOW_FIREWALL_STATUS_CODE** | Optional | `403` | HTTP status for blocked requests |
35
+ | **SECURENOW_FIREWALL_LOG** | Optional | `1` | Log blocked requests |
36
+ | **SECURENOW_FIREWALL_TCP** | Optional | `0` | Enable Layer 2 TCP blocking |
37
+ | **SECURENOW_FIREWALL_IPTABLES** | Optional | `0` | Enable Layer 3 iptables blocking |
38
+ | **SECURENOW_FIREWALL_CLOUD** | Optional | - | Cloud WAF provider (cloudflare/aws/gcp) |
39
+ | **SECURENOW_TRUSTED_PROXIES** | Optional | - | Trusted proxy IPs for X-Forwarded-For |
40
+
41
+ ---
42
+
43
+ ## Required Variables
44
+
45
+ ### SECURENOW_APPID
46
+
47
+ **Description:** Your application identifier. Used as the service name in traces and logs.
48
+
49
+ **Format:** String (alphanumeric, hyphens, underscores)
50
+
51
+ **Examples:**
52
+ ```bash
53
+ export SECURENOW_APPID=my-express-app
54
+ export SECURENOW_APPID=api-gateway
55
+ export SECURENOW_APPID=user-service
56
+ ```
57
+
58
+ **Notes:**
59
+ - If not set, SecureNow will use a fallback name with UUID
60
+ - In cluster mode with `SECURENOW_STRICT=1`, missing APPID will cause process exit
61
+ - Alternative: Use `OTEL_SERVICE_NAME` (OpenTelemetry standard)
62
+
63
+ **Behavior:**
64
+ - Without `SECURENOW_NO_UUID=1`: Service name becomes `{APPID}-{UUID}`
65
+ - With `SECURENOW_NO_UUID=1`: Service name is exactly `{APPID}`
66
+
67
+ ---
68
+
69
+ ### SECURENOW_INSTANCE
70
+
71
+ **Description:** Base URL of your OTLP collector endpoint.
72
+
73
+ **Format:** URL (http/https)
74
+
75
+ **Examples:**
76
+ ```bash
77
+ # Local collector
78
+ export SECURENOW_INSTANCE=http://localhost:4318
79
+
80
+ # Remote collector
81
+ export SECURENOW_INSTANCE=http://collector.example.com:4318
82
+
83
+ # HTTPS
84
+ export SECURENOW_INSTANCE=https://collector.example.com:4318
85
+ ```
86
+
87
+ **Default:** `https://freetrial.securenow.ai:4318` (if not set)
88
+
89
+ **Notes:**
90
+ - Used to construct traces and logs endpoints
91
+ - Traces sent to: `{SECURENOW_INSTANCE}/v1/traces`
92
+ - Logs sent to: `{SECURENOW_INSTANCE}/v1/logs`
93
+ - Alternative: Use `OTEL_EXPORTER_OTLP_ENDPOINT`
94
+
95
+ ---
96
+
97
+ ## Service Naming
98
+
99
+ ### OTEL_SERVICE_NAME
100
+
101
+ **Description:** Standard OpenTelemetry variable for service name. Alternative to `SECURENOW_APPID`.
102
+
103
+ **Format:** String
104
+
105
+ **Example:**
106
+ ```bash
107
+ export OTEL_SERVICE_NAME=my-app
108
+ ```
109
+
110
+ **Priority:** If both are set, `OTEL_SERVICE_NAME` takes precedence.
111
+
112
+ ---
113
+
114
+ ### SECURENOW_NO_UUID
115
+
116
+ **Description:** Disable automatic UUID suffix on service name.
117
+
118
+ **Format:** `1` (enabled) or `0` (disabled)
119
+
120
+ **Default:** `0`
121
+
122
+ **Example:**
123
+ ```bash
124
+ export SECURENOW_NO_UUID=1
125
+ ```
126
+
127
+ **Use case:**
128
+ - PM2 cluster mode - use same service name for all workers
129
+ - Docker containers with replica sets
130
+ - Kubernetes pods in a deployment
131
+
132
+ **Behavior:**
133
+ - `0`: Service name = `my-app-a1b2c3d4`
134
+ - `1`: Service name = `my-app`
135
+
136
+ ---
137
+
138
+ ### SECURENOW_STRICT
139
+
140
+ **Description:** Exit process if `SECURENOW_APPID` is not set in cluster mode.
141
+
142
+ **Format:** `1` (enabled) or `0` (disabled)
143
+
144
+ **Default:** `0`
145
+
146
+ **Example:**
147
+ ```bash
148
+ export SECURENOW_STRICT=1
149
+ ```
150
+
151
+ **Use case:**
152
+ - Production environments where service name must be explicit
153
+ - Prevent "free" or auto-generated service names
154
+ - Ensure proper configuration before starting
155
+
156
+ **Detection:**
157
+ Cluster mode is detected when any of these exist:
158
+ - `NODE_APP_INSTANCE` (PM2)
159
+ - `pm_id` (PM2)
160
+
161
+ ---
162
+
163
+ ## Connection Settings
164
+
165
+ ### OTEL_EXPORTER_OTLP_ENDPOINT
166
+
167
+ **Description:** Standard OpenTelemetry variable for OTLP endpoint. Alternative to `SECURENOW_INSTANCE`.
168
+
169
+ **Format:** URL
170
+
171
+ **Example:**
172
+ ```bash
173
+ export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
174
+ ```
175
+
176
+ **Priority:** If both are set, `OTEL_EXPORTER_OTLP_ENDPOINT` takes precedence.
177
+
178
+ ---
179
+
180
+ ### OTEL_EXPORTER_OTLP_TRACES_ENDPOINT
181
+
182
+ **Description:** Override the traces endpoint specifically.
183
+
184
+ **Format:** Full URL including `/v1/traces`
185
+
186
+ **Example:**
187
+ ```bash
188
+ export OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
189
+ ```
190
+
191
+ **Use case:**
192
+ - Separate collectors for traces and logs
193
+ - Different routing for traces
194
+
195
+ ---
196
+
197
+ ### OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
198
+
199
+ **Description:** Override the logs endpoint specifically.
200
+
201
+ **Format:** Full URL including `/v1/logs`
202
+
203
+ **Example:**
204
+ ```bash
205
+ export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
206
+ ```
207
+
208
+ **Use case:**
209
+ - Separate collectors for traces and logs
210
+ - Different routing for logs
211
+
212
+ ---
213
+
214
+ ### OTEL_EXPORTER_OTLP_HEADERS
215
+
216
+ **Description:** Headers to include in OTLP export requests.
217
+
218
+ **Format:** Comma-separated `key=value` pairs
219
+
220
+ **Examples:**
221
+ ```bash
222
+ # Single header
223
+ export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=your-api-key"
224
+
225
+ # Multiple headers
226
+ export OTEL_EXPORTER_OTLP_HEADERS="x-api-key=key123,x-tenant-id=tenant456"
227
+
228
+ # Authentication
229
+ export OTEL_EXPORTER_OTLP_HEADERS="authorization=Bearer token123"
230
+ ```
231
+
232
+ **Use case:**
233
+ - API authentication
234
+ - Multi-tenancy headers
235
+ - Custom routing headers
236
+
237
+ **Notes:**
238
+ - Header names are case-insensitive
239
+ - Trailing/leading spaces are trimmed
240
+
241
+ ---
242
+
243
+ ## Logging
244
+
245
+ ### SECURENOW_LOGGING_ENABLED
246
+
247
+ **Description:** Enable or disable automatic logging to OTLP backend.
248
+
249
+ **Format:** `1` (enabled) or `0` (disabled)
250
+
251
+ **Default:** `1` (enabled by default)
252
+
253
+ **Examples:**
254
+ ```bash
255
+ # Enable logging
256
+ export SECURENOW_LOGGING_ENABLED=1
257
+
258
+ # Disable logging
259
+ export SECURENOW_LOGGING_ENABLED=0
260
+ ```
261
+
262
+ **When enabled:**
263
+ - Logs are sent to `{SECURENOW_INSTANCE}/v1/logs`
264
+ - Console instrumentation can capture logs
265
+ - Direct logger API is available
266
+
267
+ **When disabled:**
268
+ - No logs sent to backend
269
+ - `getLogger()` returns `null`
270
+ - Console instrumentation shows warning
271
+
272
+ ---
273
+
274
+ ## Request Body Capture
275
+
276
+ ### SECURENOW_CAPTURE_BODY
277
+
278
+ **Description:** Enable capture of HTTP request bodies in traces.
279
+
280
+ **Format:** `1` (enabled) or `0` (disabled)
281
+
282
+ **Default:** `0` (disabled)
283
+
284
+ **Example:**
285
+ ```bash
286
+ export SECURENOW_CAPTURE_BODY=1
287
+ ```
288
+
289
+ **Supported content types:**
290
+ - `application/json`
291
+ - `application/x-www-form-urlencoded`
292
+ - `application/graphql`
293
+
294
+ **Not captured (unless separately enabled):**
295
+ - `multipart/form-data` — requires `SECURENOW_CAPTURE_MULTIPART=1` (see below)
296
+ - Bodies larger than `SECURENOW_MAX_BODY_SIZE`
297
+
298
+ **Security:**
299
+ All captured bodies are automatically scanned for sensitive fields and redacted.
300
+
301
+ ---
302
+
303
+ ### SECURENOW_MAX_BODY_SIZE
304
+
305
+ **Description:** Maximum request body size to capture (in bytes).
306
+
307
+ **Format:** Number (bytes)
308
+
309
+ **Default:** `10240` (10 KB)
310
+
311
+ **Examples:**
312
+ ```bash
313
+ # 10 KB (default)
314
+ export SECURENOW_MAX_BODY_SIZE=10240
315
+
316
+ # 20 KB
317
+ export SECURENOW_MAX_BODY_SIZE=20480
318
+
319
+ # 5 KB
320
+ export SECURENOW_MAX_BODY_SIZE=5120
321
+ ```
322
+
323
+ **Behavior:**
324
+ - Bodies larger than this are not captured
325
+ - Span attribute shows: `[TOO LARGE: {size} bytes]`
326
+
327
+ ---
328
+
329
+ ### SECURENOW_SENSITIVE_FIELDS
330
+
331
+ **Description:** Additional field names to redact from request bodies (comma-separated).
332
+
333
+ **Format:** Comma-separated list of field names
334
+
335
+ **Default:** (see below for auto-redacted fields)
336
+
337
+ **Examples:**
338
+ ```bash
339
+ # Additional custom fields
340
+ export SECURENOW_SENSITIVE_FIELDS="internal_token,session_key"
341
+
342
+ # Multiple fields
343
+ export SECURENOW_SENSITIVE_FIELDS="custom_secret,private_data,internal_id"
344
+ ```
345
+
346
+ **Auto-redacted fields (built-in):**
347
+ - `password`, `passwd`, `pwd`
348
+ - `secret`, `token`, `api_key`, `apikey`, `access_token`
349
+ - `auth`, `credentials`, `mysql_pwd`
350
+ - `stripeToken`, `card`, `cardnumber`
351
+ - `ccv`, `cvc`, `cvv`
352
+ - `ssn`, `pin`
353
+
354
+ **Matching:**
355
+ - Case-insensitive
356
+ - Substring match (e.g., `password` matches `user_password`, `PASSWORD`, `passwordField`)
357
+ - Works recursively in nested objects
358
+
359
+ ---
360
+
361
+ ### SECURENOW_CAPTURE_MULTIPART
362
+
363
+ **Description:** Enable capture of `multipart/form-data` request bodies (file upload metadata and text fields). Uses a streaming parser that processes boundary markers on the fly — file binary content is never buffered or stored.
364
+
365
+ **Format:** `1` (enabled) or `0` (disabled)
366
+
367
+ **Default:** `0` (disabled)
368
+
369
+ **Example:**
370
+ ```bash
371
+ export SECURENOW_CAPTURE_MULTIPART=1
372
+ ```
373
+
374
+ **What gets captured:**
375
+ - **Text fields** — field name and value (up to 1000 characters), with sensitive fields auto-redacted
376
+ - **File fields** — metadata only: field name, filename, content-type, and size in bytes (no binary content)
377
+
378
+ **Example span attribute (`http.request.body`):**
379
+ ```json
380
+ {
381
+ "fields": { "description": "My upload", "token": "[REDACTED]" },
382
+ "files": [
383
+ { "field": "avatar", "filename": "photo.jpg", "contentType": "image/jpeg", "size": 524288 },
384
+ { "field": "document", "filename": "report.pdf", "contentType": "application/pdf", "size": 1048576 }
385
+ ]
386
+ }
387
+ ```
388
+
389
+ **Additional span attributes set:**
390
+ - `http.request.body.type` = `"multipart"`
391
+ - `http.request.body.size` — total raw request body size in bytes
392
+ - `http.request.body.fields_count` — number of text fields
393
+ - `http.request.body.files_count` — number of file fields
394
+
395
+ **Memory:** Bounded at ~few KB regardless of upload size (streaming parser discards file content as it passes through).
396
+
397
+ **Parts limit:** 100 parts maximum per request (safety guard).
398
+
399
+ **Requires:** `SECURENOW_CAPTURE_BODY=1` must also be set (multipart capture is gated behind general body capture).
400
+
401
+ **Since:** v5.8.0
402
+
403
+ ---
404
+
405
+ ## Instrumentation Control
406
+
407
+ ### SECURENOW_DISABLE_INSTRUMENTATIONS
408
+
409
+ **Description:** Disable specific OpenTelemetry instrumentations.
410
+
411
+ **Format:** Comma-separated list of package names
412
+
413
+ **Example:**
414
+ ```bash
415
+ # Disable file system and DNS instrumentations
416
+ export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns
417
+
418
+ # Disable multiple
419
+ export SECURENOW_DISABLE_INSTRUMENTATIONS=fs,dns,net,http2
420
+ ```
421
+
422
+ **Common packages you might disable:**
423
+ - `fs` - File system operations
424
+ - `dns` - DNS lookups
425
+ - `net` - Network operations
426
+ - `http2` - HTTP/2 client/server
427
+ - `grpc` - gRPC client/server
428
+
429
+ **Use case:**
430
+ - Reduce overhead by disabling unused instrumentations
431
+ - Avoid noisy traces from certain operations
432
+ - Debug issues with specific instrumentations
433
+
434
+ ---
435
+
436
+ ## Debugging
437
+
438
+ ### OTEL_LOG_LEVEL
439
+
440
+ **Description:** OpenTelemetry SDK internal log level.
441
+
442
+ **Format:** `none`, `error`, `warn`, `info`, `debug`
443
+
444
+ **Default:** `none`
445
+
446
+ **Examples:**
447
+ ```bash
448
+ # See all debug information
449
+ export OTEL_LOG_LEVEL=debug
450
+
451
+ # Only errors
452
+ export OTEL_LOG_LEVEL=error
453
+
454
+ # No SDK logs
455
+ export OTEL_LOG_LEVEL=none
456
+ ```
457
+
458
+ **Use case:**
459
+ - Troubleshooting setup issues
460
+ - Understanding trace/log export behavior
461
+ - Debugging connection problems
462
+
463
+ **Output:**
464
+ - Goes to console (stderr)
465
+ - Prefixed with `[securenow]`
466
+
467
+ ---
468
+
469
+ ### SECURENOW_TEST_SPAN
470
+
471
+ **Description:** Emit a test span on startup to verify tracing is working.
472
+
473
+ **Format:** `1` (enabled) or `0` (disabled)
474
+
475
+ **Default:** `0`
476
+
477
+ **Example:**
478
+ ```bash
479
+ export SECURENOW_TEST_SPAN=1
480
+ ```
481
+
482
+ **Behavior:**
483
+ - Creates a span named `securenow.startup.smoke`
484
+ - Span is immediately ended
485
+ - Useful for testing collector connectivity
486
+
487
+ ---
488
+
489
+ ## Environment
490
+
491
+ ### NODE_ENV
492
+
493
+ **Description:** Standard Node.js environment variable. Sent as `deployment.environment` attribute.
494
+
495
+ **Format:** String (typically: `development`, `production`, `test`, `staging`)
496
+
497
+ **Default:** `production`
498
+
499
+ **Examples:**
500
+ ```bash
501
+ export NODE_ENV=development
502
+ export NODE_ENV=production
503
+ export NODE_ENV=staging
504
+ export NODE_ENV=test
505
+ ```
506
+
507
+ **Use case:**
508
+ - Filter traces/logs by environment
509
+ - Different configurations per environment
510
+ - Standard Node.js convention
511
+
512
+ ---
513
+
514
+ ## Firewall (IP Blocking)
515
+
516
+ ### SECURENOW_API_KEY
517
+
518
+ **Description:** API key for the SecureNow firewall. When set, the firewall auto-activates and syncs your blocklist. Must have the `firewall:read` scope.
519
+
520
+ **Format:** String (`snk_live_` prefix + 64 hex characters)
521
+
522
+ **Example:**
523
+ ```bash
524
+ export SECURENOW_API_KEY=snk_live_a1b2c3d4e5f6...
525
+ ```
526
+
527
+ ---
528
+
529
+ ### SECURENOW_API_URL
530
+
531
+ **Description:** Base URL for the SecureNow API.
532
+
533
+ **Format:** URL
534
+
535
+ **Default:** `https://api.securenow.ai`
536
+
537
+ **Example:**
538
+ ```bash
539
+ export SECURENOW_API_URL=https://api.securenow.ai
540
+ ```
541
+
542
+ ---
543
+
544
+ ### SECURENOW_FIREWALL_ENABLED
545
+
546
+ **Description:** Master kill-switch for the firewall. Set to `0` to disable even when `SECURENOW_API_KEY` is set.
547
+
548
+ **Format:** `1` (enabled) or `0` (disabled)
549
+
550
+ **Default:** `1`
551
+
552
+ ---
553
+
554
+ ### SECURENOW_FIREWALL_SYNC_INTERVAL
555
+
556
+ **Description:** How often (in seconds) to refresh the blocklist from the API.
557
+
558
+ **Format:** Number (seconds)
559
+
560
+ **Default:** `60`
561
+
562
+ **Example:**
563
+ ```bash
564
+ export SECURENOW_FIREWALL_SYNC_INTERVAL=30
565
+ ```
566
+
567
+ ---
568
+
569
+ ### SECURENOW_FIREWALL_FAIL_MODE
570
+
571
+ **Description:** Behavior when the blocklist cannot be fetched from the API.
572
+
573
+ **Format:** `open` or `closed`
574
+
575
+ **Default:** `open`
576
+
577
+ - `open` — Allow all traffic when list is unavailable (recommended for most apps)
578
+ - `closed` — Block all traffic when list is unavailable (high-security environments)
579
+
580
+ ---
581
+
582
+ ### SECURENOW_FIREWALL_STATUS_CODE
583
+
584
+ **Description:** HTTP status code returned to blocked requests (Layer 1 only).
585
+
586
+ **Format:** Number
587
+
588
+ **Default:** `403`
589
+
590
+ **Example:**
591
+ ```bash
592
+ export SECURENOW_FIREWALL_STATUS_CODE=429
593
+ ```
594
+
595
+ ---
596
+
597
+ ### SECURENOW_FIREWALL_LOG
598
+
599
+ **Description:** Log blocked requests to the console.
600
+
601
+ **Format:** `1` (enabled) or `0` (disabled)
602
+
603
+ **Default:** `1`
604
+
605
+ ---
606
+
607
+ ### SECURENOW_FIREWALL_TCP
608
+
609
+ **Description:** Enable Layer 2 TCP-level blocking. Destroys sockets from blocked IPs before HTTP parsing starts.
610
+
611
+ **Format:** `1` (enabled) or `0` (disabled)
612
+
613
+ **Default:** `0`
614
+
615
+ **Notes:**
616
+ - Only sees direct connection IP (no proxy headers)
617
+ - Connections from trusted proxies are passed to Layer 1
618
+ - Most effective for direct-to-server deployments
619
+
620
+ ---
621
+
622
+ ### SECURENOW_FIREWALL_IPTABLES
623
+
624
+ **Description:** Enable Layer 3 OS firewall blocking via iptables/nftables. Kernel-level DROP — packets never reach Node.js.
625
+
626
+ **Format:** `1` (enabled) or `0` (disabled)
627
+
628
+ **Default:** `0`
629
+
630
+ **Notes:**
631
+ - Linux only (skips gracefully on macOS/Windows)
632
+ - Requires root or CAP_NET_ADMIN
633
+ - Auto-detects nftables vs iptables
634
+ - Dedicated chain: `SECURENOW_BLOCK`
635
+
636
+ ---
637
+
638
+ ### SECURENOW_FIREWALL_CLOUD
639
+
640
+ **Description:** Enable Layer 4 cloud/edge WAF blocking. Pushes the blocklist to your cloud provider's WAF.
641
+
642
+ **Format:** `cloudflare`, `aws`, or `gcp`
643
+
644
+ **Default:** *(none — disabled)*
645
+
646
+ **Provider-specific variables:**
647
+
648
+ | Provider | Required Variables |
649
+ |----------|-------------------|
650
+ | `cloudflare` | `CLOUDFLARE_API_TOKEN`, `CLOUDFLARE_ACCOUNT_ID` |
651
+ | `aws` | `AWS_WAF_IP_SET_ID`, standard AWS credentials |
652
+ | `gcp` | `GCP_PROJECT_ID`, `GCP_SECURITY_POLICY` |
653
+
654
+ ---
655
+
656
+ ### SECURENOW_FIREWALL_CLOUD_DRY_RUN
657
+
658
+ **Description:** Log cloud WAF pushes without actually applying them. Useful for testing.
659
+
660
+ **Format:** `1` (enabled) or `0` (disabled)
661
+
662
+ **Default:** `0`
663
+
664
+ ---
665
+
666
+ ### SECURENOW_TRUSTED_PROXIES
667
+
668
+ **Description:** Comma-separated list of additional trusted proxy IPs. The firewall only reads `X-Forwarded-For` from trusted proxies. Private/loopback IPs are always trusted.
669
+
670
+ **Format:** Comma-separated IPs
671
+
672
+ **Example:**
673
+ ```bash
674
+ export SECURENOW_TRUSTED_PROXIES=34.120.0.1,34.120.0.2
675
+ ```
676
+
677
+ ---
678
+
679
+ ## Configuration Examples
680
+
681
+ ### Development Environment
682
+
683
+ ```bash
684
+ # .env.development
685
+ SECURENOW_APPID=my-app-dev
686
+ SECURENOW_INSTANCE=http://localhost:4318
687
+ SECURENOW_LOGGING_ENABLED=1
688
+ SECURENOW_CAPTURE_BODY=1
689
+ SECURENOW_MAX_BODY_SIZE=20480
690
+ OTEL_LOG_LEVEL=debug
691
+ SECURENOW_TEST_SPAN=1
692
+ NODE_ENV=development
693
+ ```
694
+
695
+ ### Production Environment
696
+
697
+ ```bash
698
+ # .env.production
699
+ SECURENOW_APPID=my-app-prod
700
+ SECURENOW_INSTANCE=https://collector.prod.example.com:4318
701
+ OTEL_EXPORTER_OTLP_HEADERS=x-api-key=prod-key-12345
702
+ SECURENOW_LOGGING_ENABLED=1
703
+ SECURENOW_CAPTURE_BODY=0
704
+ SECURENOW_NO_UUID=1
705
+ SECURENOW_STRICT=1
706
+ SECURENOW_SENSITIVE_FIELDS=internal_id,session_token
707
+ OTEL_LOG_LEVEL=error
708
+ NODE_ENV=production
709
+
710
+ # Firewall (optional — auto-activates when API key is set)
711
+ SECURENOW_API_KEY=snk_live_abc123...
712
+ SECURENOW_FIREWALL_TCP=1
713
+ SECURENOW_FIREWALL_SYNC_INTERVAL=30
714
+ ```
715
+
716
+ ### PM2 Cluster
717
+
718
+ ```bash
719
+ # ecosystem.config.js environment
720
+ SECURENOW_APPID=my-app
721
+ SECURENOW_INSTANCE=http://localhost:4318
722
+ SECURENOW_LOGGING_ENABLED=1
723
+ SECURENOW_NO_UUID=1
724
+ SECURENOW_STRICT=1
725
+ SECURENOW_CAPTURE_BODY=1
726
+ NODE_ENV=production
727
+ ```
728
+
729
+ ### Docker / Kubernetes
730
+
731
+ ```bash
732
+ # Docker environment or K8s ConfigMap
733
+ SECURENOW_APPID=my-service
734
+ SECURENOW_INSTANCE=http://otel-collector:4318
735
+ SECURENOW_LOGGING_ENABLED=1
736
+ SECURENOW_NO_UUID=1
737
+ SECURENOW_CAPTURE_BODY=0
738
+ NODE_ENV=production
739
+ ```
740
+
741
+ ### Separate Collectors for Traces and Logs
742
+
743
+ ```bash
744
+ # Different backends for traces and logs
745
+ SECURENOW_APPID=my-app
746
+ OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://traces-collector:4318/v1/traces
747
+ OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=http://logs-collector:4318/v1/logs
748
+ SECURENOW_LOGGING_ENABLED=1
749
+ ```
750
+
751
+ ---
752
+
753
+ ## Priority and Overrides
754
+
755
+ When multiple variables are set, this is the priority order:
756
+
757
+ ### Service Name
758
+
759
+ 1. `OTEL_SERVICE_NAME` (highest priority)
760
+ 2. `SECURENOW_APPID`
761
+ 3. Auto-generated fallback (lowest priority)
762
+
763
+ ### OTLP Endpoint
764
+
765
+ 1. `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` (for traces)
766
+ 2. `OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` (for logs)
767
+ 3. `OTEL_EXPORTER_OTLP_ENDPOINT`
768
+ 4. `SECURENOW_INSTANCE`
769
+ 5. Default: `https://freetrial.securenow.ai:4318` (lowest priority)
770
+
771
+ ---
772
+
773
+ ## Validation
774
+
775
+ SecureNow validates environment variables on startup. Check console output:
776
+
777
+ ```bash
778
+ [securenow] pid=12345 SECURENOW_APPID="my-app" OTEL_SERVICE_NAME=null → service.name=my-app-uuid123
779
+ [securenow] OTel SDK started → http://localhost:4318/v1/traces
780
+ [securenow] 📋 Logging: ENABLED → http://localhost:4318/v1/logs
781
+ [securenow] 📝 Request body capture: ENABLED (max: 10240 bytes)
782
+ ```
783
+
784
+ ---
785
+
786
+ ## Best Practices
787
+
788
+ ### 1. Use .env Files
789
+
790
+ Don't hardcode in your application:
791
+
792
+ ```bash
793
+ # .env
794
+ SECURENOW_APPID=my-app
795
+ SECURENOW_INSTANCE=http://localhost:4318
796
+ ```
797
+
798
+ ### 2. Different Configs per Environment
799
+
800
+ ```bash
801
+ # .env.development
802
+ SECURENOW_CAPTURE_BODY=1
803
+ OTEL_LOG_LEVEL=debug
804
+
805
+ # .env.production
806
+ SECURENOW_CAPTURE_BODY=0
807
+ OTEL_LOG_LEVEL=error
808
+ ```
809
+
810
+ ### 3. Use SECURENOW_NO_UUID in Clusters
811
+
812
+ ```bash
813
+ # PM2 cluster with 4 workers
814
+ SECURENOW_NO_UUID=1
815
+ ```
816
+
817
+ ### 4. Enable SECURENOW_STRICT in Production
818
+
819
+ ```bash
820
+ # Fail fast if misconfigured
821
+ SECURENOW_STRICT=1
822
+ ```
823
+
824
+ ### 5. Disable Body Capture in Production
825
+
826
+ ```bash
827
+ # Development
828
+ SECURENOW_CAPTURE_BODY=1
829
+
830
+ # Production
831
+ SECURENOW_CAPTURE_BODY=0
832
+ ```
833
+
834
+ ---
835
+
836
+ ## Troubleshooting
837
+
838
+ ### Check Current Values
839
+
840
+ ```bash
841
+ # Print all SECURENOW variables
842
+ env | grep SECURENOW
843
+
844
+ # Print all OTEL variables
845
+ env | grep OTEL
846
+
847
+ # Check specific variable
848
+ echo $SECURENOW_APPID
849
+ ```
850
+
851
+ ### Verify in Application
852
+
853
+ SecureNow logs current configuration on startup. Look for lines like:
854
+
855
+ ```
856
+ [securenow] pid=12345 SECURENOW_APPID="my-app" → service.name=my-app
857
+ [securenow] OTel SDK started → http://localhost:4318/v1/traces
858
+ ```
859
+
860
+ ### Enable Debug Mode
861
+
862
+ ```bash
863
+ export OTEL_LOG_LEVEL=debug
864
+ node app.js
865
+ ```
866
+
867
+ ---
868
+
869
+ ## Related Documentation
870
+
871
+ - [Firewall Guide](./FIREWALL-GUIDE.md)
872
+ - [API Keys Guide](./API-KEYS-GUIDE.md)
873
+ - [Express Setup Guide](./EXPRESS-SETUP-GUIDE.md)
874
+ - [Next.js Setup Guide](./NEXTJS-SETUP-COMPLETE.md)
875
+ - [Logging Guide](./LOGGING-GUIDE.md)
876
+ - [NPM README](../NPM_README.md)
877
+
878
+ ---
879
+
880
+ **Complete reference for all SecureNow environment variables.** 🎯