@robiki/proxy 1.0.2 → 1.0.4
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.
- package/README.de.md +101 -395
- package/README.es.md +100 -394
- package/README.ja.md +101 -395
- package/README.md +101 -395
- package/README.pl.md +101 -395
- package/README.ru.md +100 -394
- package/README.zh.md +100 -394
- package/dist/{config-CeJ1tf8T.d.ts → config-Bmt0asXb.d.ts} +5 -11
- package/dist/config-C-0wrirG.js +315 -0
- package/dist/{config-CQ7zIaQt.d.ts → config-CCOdQL7F.d.ts} +7 -11
- package/dist/{config-_6LOsppp.d.ts → config-DtfpOtWI.d.ts} +30 -73
- package/dist/index.d.ts +14 -2
- package/dist/index.js +30 -58
- package/dist/utils/config.d.ts +1 -1
- package/dist/utils/config.js +3 -215
- package/package.json +2 -5
package/README.de.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
# 🚀 Robiki Proxy
|
|
2
2
|
|
|
3
|
-
> Ein leistungsstarker
|
|
3
|
+
> Ein leistungsstarker HTTP/2-Reverse-Proxy mit WebSocket-Unterstützung, konfigurierbarem Routing, CORS und Anforderungsvalidierung. Als npm-Paket oder Docker-Container für lokale Entwicklungsumgebungen verwendbar.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@robiki/proxy)
|
|
6
6
|
[](https://opensource.org/licenses/MIT)
|
|
7
7
|
|
|
8
|
-
## 🌍 Sprachen
|
|
8
|
+
## 🌍 Sprachen
|
|
9
9
|
|
|
10
10
|
[English](README.md) | [Deutsch](README.de.md) | [中文](README.zh.md) | [日本語](README.ja.md) | [Polski](README.pl.md) | [Español](README.es.md) | [Русский](README.ru.md)
|
|
11
11
|
|
|
@@ -18,54 +18,29 @@
|
|
|
18
18
|
- **✅ Anforderungsvalidierung**: Benutzerdefinierte Validierungslogik für Authentifizierung, Rate Limiting usw.
|
|
19
19
|
- **🔄 URL-Remapping**: URLs vor der Weiterleitung an Zieldienste transformieren
|
|
20
20
|
- **📦 Duale Nutzung**: Als npm-Paket oder Docker-Container verwenden
|
|
21
|
+
- **⚙️ JavaScript & TypeScript-Konfigurationsunterstützung**: Verwenden Sie `.js` oder `.ts`-Konfigurationsdateien mit Funktionen in Docker
|
|
21
22
|
- **🎯 Multi-Port-Unterstützung**: Gleichzeitiges Lauschen auf mehreren Ports
|
|
22
23
|
- **⚡ Hohe Leistung**: Basiert auf der nativen HTTP/2-Implementierung von Node.js
|
|
23
24
|
|
|
24
25
|
## 📦 Installation
|
|
25
26
|
|
|
26
|
-
###
|
|
27
|
+
### npm-Paket
|
|
27
28
|
|
|
28
29
|
```bash
|
|
29
30
|
npm install @robiki/proxy
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
```bash
|
|
31
|
+
# oder
|
|
33
32
|
yarn add @robiki/proxy
|
|
34
33
|
```
|
|
35
34
|
|
|
36
|
-
###
|
|
35
|
+
### Docker
|
|
37
36
|
|
|
38
37
|
```bash
|
|
39
38
|
docker pull robiki/proxy:latest
|
|
40
39
|
```
|
|
41
40
|
|
|
42
|
-
### Als Docker Compose Service
|
|
43
|
-
|
|
44
|
-
```yaml
|
|
45
|
-
services:
|
|
46
|
-
proxy:
|
|
47
|
-
image: robiki/proxy:latest
|
|
48
|
-
container_name: robiki-proxy
|
|
49
|
-
restart: unless-stopped
|
|
50
|
-
ports:
|
|
51
|
-
- '443:443'
|
|
52
|
-
- '8080:8080'
|
|
53
|
-
- '9229:9229'
|
|
54
|
-
volumes:
|
|
55
|
-
- ./proxy.config.json:/app/proxy.config.json:ro
|
|
56
|
-
- ./certs:/app/certs:ro
|
|
57
|
-
networks:
|
|
58
|
-
- app-network
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
## Hinweise
|
|
62
|
-
|
|
63
|
-
- Hosts, die lokal konfiguriert sind, sollten zu Ihrer lokalen `hosts`-Datei hinzugefügt werden.
|
|
64
|
-
- Wenn Sie benutzerdefinierte Zertifikate verwenden, müssen Sie die Zertifikatdateien zum `certs`-Verzeichnis hinzufügen.
|
|
65
|
-
|
|
66
41
|
## 🚀 Schnellstart
|
|
67
42
|
|
|
68
|
-
###
|
|
43
|
+
### npm-Paket
|
|
69
44
|
|
|
70
45
|
```javascript
|
|
71
46
|
import { createProxy } from '@robiki/proxy';
|
|
@@ -88,13 +63,11 @@ const proxy = await createProxy({
|
|
|
88
63
|
},
|
|
89
64
|
},
|
|
90
65
|
});
|
|
91
|
-
|
|
92
|
-
console.log('Proxy-Server läuft!');
|
|
93
66
|
```
|
|
94
67
|
|
|
95
|
-
###
|
|
68
|
+
### Docker
|
|
96
69
|
|
|
97
|
-
|
|
70
|
+
Erstellen Sie `proxy.config.json`:
|
|
98
71
|
|
|
99
72
|
```json
|
|
100
73
|
{
|
|
@@ -108,20 +81,14 @@ console.log('Proxy-Server läuft!');
|
|
|
108
81
|
"api.example.com": {
|
|
109
82
|
"target": "backend-service:3000",
|
|
110
83
|
"ssl": true
|
|
111
|
-
},
|
|
112
|
-
"example.com": {
|
|
113
|
-
"target": "frontend-service:8080",
|
|
114
|
-
"ssl": false
|
|
115
84
|
}
|
|
116
85
|
}
|
|
117
86
|
}
|
|
118
87
|
```
|
|
119
88
|
|
|
120
|
-
|
|
89
|
+
Erstellen Sie `docker-compose.yml`:
|
|
121
90
|
|
|
122
91
|
```yaml
|
|
123
|
-
version: '3.8'
|
|
124
|
-
|
|
125
92
|
services:
|
|
126
93
|
proxy:
|
|
127
94
|
image: robiki/proxy:latest
|
|
@@ -133,25 +100,9 @@ services:
|
|
|
133
100
|
- ./certs:/app/certs:ro
|
|
134
101
|
environment:
|
|
135
102
|
- PROXY_CONFIG=/app/proxy.config.json
|
|
136
|
-
networks:
|
|
137
|
-
- app-network
|
|
138
|
-
|
|
139
|
-
backend-service:
|
|
140
|
-
image: your-backend-image
|
|
141
|
-
networks:
|
|
142
|
-
- app-network
|
|
143
|
-
|
|
144
|
-
frontend-service:
|
|
145
|
-
image: your-frontend-image
|
|
146
|
-
networks:
|
|
147
|
-
- app-network
|
|
148
|
-
|
|
149
|
-
networks:
|
|
150
|
-
app-network:
|
|
151
|
-
driver: bridge
|
|
152
103
|
```
|
|
153
104
|
|
|
154
|
-
|
|
105
|
+
Starten:
|
|
155
106
|
|
|
156
107
|
```bash
|
|
157
108
|
docker-compose up -d
|
|
@@ -159,9 +110,9 @@ docker-compose up -d
|
|
|
159
110
|
|
|
160
111
|
## 📖 Konfiguration
|
|
161
112
|
|
|
162
|
-
###
|
|
113
|
+
### JSON-Konfiguration
|
|
163
114
|
|
|
164
|
-
|
|
115
|
+
Einfache deklarative Konfiguration:
|
|
165
116
|
|
|
166
117
|
```json
|
|
167
118
|
{
|
|
@@ -169,24 +120,17 @@ Erstellen Sie eine `proxy.config.json`-Datei mit folgender Struktur:
|
|
|
169
120
|
"ssl": {
|
|
170
121
|
"key": "./certs/key.pem",
|
|
171
122
|
"cert": "./certs/cert.pem",
|
|
172
|
-
"ca": "./certs/ca.pem",
|
|
173
123
|
"allowHTTP1": true
|
|
174
124
|
},
|
|
175
125
|
"cors": {
|
|
176
126
|
"origin": "*",
|
|
177
|
-
"methods": ["GET", "POST", "PUT", "DELETE"
|
|
178
|
-
"
|
|
179
|
-
"credentials": true,
|
|
180
|
-
"maxAge": 86400
|
|
127
|
+
"methods": ["GET", "POST", "PUT", "DELETE"],
|
|
128
|
+
"credentials": true
|
|
181
129
|
},
|
|
182
130
|
"routes": {
|
|
183
131
|
"api.example.com": {
|
|
184
|
-
"target": "backend
|
|
185
|
-
"ssl": true
|
|
186
|
-
"cors": {
|
|
187
|
-
"origin": ["https://example.com"],
|
|
188
|
-
"credentials": true
|
|
189
|
-
}
|
|
132
|
+
"target": "backend:3000",
|
|
133
|
+
"ssl": true
|
|
190
134
|
},
|
|
191
135
|
"*.example.com": {
|
|
192
136
|
"target": "wildcard-service:4000",
|
|
@@ -196,78 +140,32 @@ Erstellen Sie eine `proxy.config.json`-Datei mit folgender Struktur:
|
|
|
196
140
|
}
|
|
197
141
|
```
|
|
198
142
|
|
|
199
|
-
###
|
|
200
|
-
|
|
201
|
-
Sie können den Proxy auch über Umgebungsvariablen konfigurieren:
|
|
202
|
-
|
|
203
|
-
```bash
|
|
204
|
-
# SSL-Konfiguration
|
|
205
|
-
SSL_KEY=/app/certs/key.pem
|
|
206
|
-
SSL_CERT=/app/certs/cert.pem
|
|
207
|
-
SSL_CA=/app/certs/ca.pem
|
|
208
|
-
SSL_ALLOW_HTTP1=true
|
|
209
|
-
|
|
210
|
-
# CORS-Konfiguration
|
|
211
|
-
CORS_ORIGIN=*
|
|
212
|
-
CORS_METHODS=GET,POST,PUT,DELETE,OPTIONS
|
|
213
|
-
CORS_HEADERS=Content-Type,Authorization
|
|
214
|
-
CORS_CREDENTIALS=true
|
|
215
|
-
|
|
216
|
-
# Debug-Modus
|
|
217
|
-
DEBUG=true # Aktiviert detailliertes Logging für Proxy-Verbindungen und Fehler
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
## 🎯 Erweiterte Verwendung
|
|
221
|
-
|
|
222
|
-
### URL-Remapping
|
|
223
|
-
|
|
224
|
-
URLs vor der Weiterleitung an Zieldienste transformieren:
|
|
225
|
-
|
|
226
|
-
```javascript
|
|
227
|
-
const config = {
|
|
228
|
-
routes: {
|
|
229
|
-
'api.example.com': {
|
|
230
|
-
target: 'backend:3000',
|
|
231
|
-
ssl: true,
|
|
232
|
-
remap: (url) => {
|
|
233
|
-
// /api-Präfix entfernen
|
|
234
|
-
return url.replace(/^\/api/, '');
|
|
235
|
-
},
|
|
236
|
-
},
|
|
237
|
-
},
|
|
238
|
-
};
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### Anforderungsvalidierung
|
|
143
|
+
### JavaScript-Konfiguration
|
|
242
144
|
|
|
243
|
-
|
|
145
|
+
Für erweiterte Funktionen wie URL-Remapping und Validierung:
|
|
244
146
|
|
|
245
147
|
```javascript
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
message: 'Nicht autorisiert',
|
|
254
|
-
headers: { 'www-authenticate': 'Bearer' },
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
return { status: true };
|
|
148
|
+
// proxy.config.js
|
|
149
|
+
export default {
|
|
150
|
+
ports: [443, 8080],
|
|
151
|
+
ssl: {
|
|
152
|
+
key: './certs/key.pem',
|
|
153
|
+
cert: './certs/cert.pem',
|
|
154
|
+
allowHTTP1: true,
|
|
258
155
|
},
|
|
259
156
|
routes: {
|
|
260
157
|
'api.example.com': {
|
|
261
158
|
target: 'backend:3000',
|
|
262
159
|
ssl: true,
|
|
263
|
-
//
|
|
160
|
+
// URL-Remapping
|
|
161
|
+
remap: (url) => url.replace(/^\/api/, ''),
|
|
162
|
+
// Anforderungsvalidierung
|
|
264
163
|
validate: async (info) => {
|
|
265
|
-
|
|
266
|
-
if (!rateLimit.allowed) {
|
|
164
|
+
if (!info.headers.authorization) {
|
|
267
165
|
return {
|
|
268
166
|
status: false,
|
|
269
|
-
code:
|
|
270
|
-
message: '
|
|
167
|
+
code: 401,
|
|
168
|
+
message: 'Unauthorized',
|
|
271
169
|
};
|
|
272
170
|
}
|
|
273
171
|
return { status: true };
|
|
@@ -277,93 +175,80 @@ const config = {
|
|
|
277
175
|
};
|
|
278
176
|
```
|
|
279
177
|
|
|
280
|
-
###
|
|
178
|
+
### TypeScript-Konfiguration
|
|
281
179
|
|
|
282
|
-
|
|
180
|
+
Typsichere Konfiguration mit vollständiger IDE-Unterstützung:
|
|
283
181
|
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
182
|
+
```typescript
|
|
183
|
+
// proxy.config.ts
|
|
184
|
+
import type { ServerConfig, ConnectionInfo } from '@robiki/proxy';
|
|
185
|
+
|
|
186
|
+
const config: ServerConfig = {
|
|
187
|
+
ports: [443, 8080],
|
|
188
|
+
ssl: {
|
|
189
|
+
key: './certs/key.pem',
|
|
190
|
+
cert: './certs/cert.pem',
|
|
191
|
+
allowHTTP1: true,
|
|
293
192
|
},
|
|
294
193
|
routes: {
|
|
295
194
|
'api.example.com': {
|
|
296
195
|
target: 'backend:3000',
|
|
297
196
|
ssl: true,
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
197
|
+
remap: (url: string) => url.replace(/^\/api/, ''),
|
|
198
|
+
validate: async (info: ConnectionInfo) => {
|
|
199
|
+
if (!info.headers['x-api-key']) {
|
|
200
|
+
return { status: false, code: 401, message: 'API Key Required' };
|
|
201
|
+
}
|
|
202
|
+
return { status: true };
|
|
302
203
|
},
|
|
303
204
|
},
|
|
304
205
|
},
|
|
305
206
|
};
|
|
306
|
-
```
|
|
307
207
|
|
|
308
|
-
|
|
208
|
+
export default config;
|
|
209
|
+
```
|
|
309
210
|
|
|
310
|
-
|
|
211
|
+
### Umgebungsvariablen
|
|
311
212
|
|
|
312
|
-
```
|
|
313
|
-
|
|
213
|
+
```bash
|
|
214
|
+
# SSL-Konfiguration
|
|
215
|
+
SSL_KEY=/app/certs/key.pem
|
|
216
|
+
SSL_CERT=/app/certs/cert.pem
|
|
217
|
+
SSL_ALLOW_HTTP1=true
|
|
314
218
|
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
// Auf Standard-Proxy-Verhalten zurückfallen
|
|
321
|
-
const { restAPIProxyHandler } = await import('@robiki/proxy/connections');
|
|
322
|
-
return restAPIProxyHandler(req, res);
|
|
323
|
-
};
|
|
219
|
+
# CORS-Konfiguration
|
|
220
|
+
CORS_ORIGIN=*
|
|
221
|
+
CORS_METHODS=GET,POST,PUT,DELETE
|
|
222
|
+
CORS_CREDENTIALS=true
|
|
324
223
|
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
websocket: customWebSocketHandler,
|
|
328
|
-
stream: customStreamHandler,
|
|
329
|
-
});
|
|
224
|
+
# Debug-Modus
|
|
225
|
+
DEBUG=true
|
|
330
226
|
```
|
|
331
227
|
|
|
332
228
|
## 🔧 API-Referenz
|
|
333
229
|
|
|
334
|
-
### `createProxy(config: ServerConfig)
|
|
335
|
-
|
|
336
|
-
Erstellt und startet einen Proxy-Server mit der angegebenen Konfiguration.
|
|
337
|
-
|
|
338
|
-
**Parameter:**
|
|
339
|
-
|
|
340
|
-
- `config`: Server-Konfigurationsobjekt
|
|
341
|
-
|
|
342
|
-
**Rückgabe:** Promise, das zu einer `ProxyServer`-Instanz aufgelöst wird
|
|
343
|
-
|
|
344
|
-
### `ProxyServer`
|
|
345
|
-
|
|
346
|
-
**Methoden:**
|
|
347
|
-
|
|
348
|
-
- `start()`: Proxy-Server starten
|
|
349
|
-
- `stop()`: Proxy-Server stoppen
|
|
350
|
-
- `getConfig()`: Aktuelle Konfiguration abrufen
|
|
230
|
+
### `createProxy(config: ServerConfig)`
|
|
351
231
|
|
|
352
|
-
|
|
232
|
+
Erstellt und startet einen Proxy-Server.
|
|
353
233
|
|
|
354
|
-
|
|
234
|
+
**ServerConfig:**
|
|
355
235
|
|
|
356
236
|
```typescript
|
|
357
237
|
interface ServerConfig {
|
|
358
238
|
ports?: number[];
|
|
359
|
-
ssl?:
|
|
239
|
+
ssl?: {
|
|
240
|
+
key: string;
|
|
241
|
+
cert: string;
|
|
242
|
+
ca?: string;
|
|
243
|
+
allowHTTP1?: boolean;
|
|
244
|
+
};
|
|
360
245
|
routes: Record<string, RouteConfig>;
|
|
361
246
|
cors?: CorsConfig;
|
|
362
247
|
validate?: (info: ConnectionInfo) => Promise<ForwardValidationResult>;
|
|
363
248
|
}
|
|
364
249
|
```
|
|
365
250
|
|
|
366
|
-
|
|
251
|
+
**RouteConfig:**
|
|
367
252
|
|
|
368
253
|
```typescript
|
|
369
254
|
interface RouteConfig {
|
|
@@ -375,265 +260,86 @@ interface RouteConfig {
|
|
|
375
260
|
}
|
|
376
261
|
```
|
|
377
262
|
|
|
378
|
-
#### `CorsConfig`
|
|
379
|
-
|
|
380
|
-
```typescript
|
|
381
|
-
interface CorsConfig {
|
|
382
|
-
origin?: string | string[];
|
|
383
|
-
methods?: string[];
|
|
384
|
-
allowedHeaders?: string[];
|
|
385
|
-
exposedHeaders?: string[];
|
|
386
|
-
credentials?: boolean;
|
|
387
|
-
maxAge?: number;
|
|
388
|
-
}
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
#### `ConnectionInfo`
|
|
392
|
-
|
|
393
|
-
```typescript
|
|
394
|
-
interface ConnectionInfo {
|
|
395
|
-
id: number;
|
|
396
|
-
method: string;
|
|
397
|
-
path: string;
|
|
398
|
-
remoteAddress: string;
|
|
399
|
-
scheme: string;
|
|
400
|
-
authority: string;
|
|
401
|
-
origin: string;
|
|
402
|
-
headers: IncomingHttpHeaders;
|
|
403
|
-
query: URLSearchParams;
|
|
404
|
-
type: RequestType;
|
|
405
|
-
}
|
|
406
|
-
```
|
|
407
|
-
|
|
408
263
|
## 🐳 Docker-Verwendung
|
|
409
264
|
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
1. Fügen Sie den Proxy zu Ihrer `docker-compose.yml` hinzu:
|
|
265
|
+
Mounten Sie Ihre Konfigurationsdatei (JSON, .cjs oder .ts):
|
|
413
266
|
|
|
414
267
|
```yaml
|
|
415
268
|
services:
|
|
416
269
|
proxy:
|
|
417
270
|
image: robiki/proxy:latest
|
|
418
|
-
ports:
|
|
419
|
-
- '443:443'
|
|
420
|
-
- '8080:8080'
|
|
421
271
|
volumes:
|
|
422
|
-
- ./proxy.config.
|
|
272
|
+
- ./proxy.config.cjs:/app/proxy.config.cjs:ro
|
|
423
273
|
- ./certs:/app/certs:ro
|
|
424
|
-
|
|
425
|
-
-
|
|
426
|
-
|
|
427
|
-
your-service:
|
|
428
|
-
image: your-service-image
|
|
429
|
-
networks:
|
|
430
|
-
- your-network
|
|
431
|
-
```
|
|
432
|
-
|
|
433
|
-
2. Konfigurieren Sie Routen in `proxy.config.json`, um auf Ihre Dienste zu verweisen
|
|
434
|
-
|
|
435
|
-
3. Starten Sie Ihren Stack:
|
|
436
|
-
|
|
437
|
-
```bash
|
|
438
|
-
docker-compose up -d
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
### Benutzerdefiniertes Image erstellen
|
|
442
|
-
|
|
443
|
-
Erstellen Sie ein benutzerdefiniertes Dockerfile:
|
|
444
|
-
|
|
445
|
-
```dockerfile
|
|
446
|
-
FROM robiki/proxy:latest
|
|
447
|
-
|
|
448
|
-
# Kopieren Sie Ihre Konfiguration
|
|
449
|
-
COPY proxy.config.json /app/proxy.config.json
|
|
450
|
-
COPY certs /app/certs
|
|
451
|
-
|
|
452
|
-
# Umgebungsvariablen setzen
|
|
453
|
-
ENV PROXY_CONFIG=/app/proxy.config.json
|
|
274
|
+
environment:
|
|
275
|
+
- PROXY_CONFIG=/app/proxy.config.cjs
|
|
454
276
|
```
|
|
455
277
|
|
|
456
|
-
##
|
|
457
|
-
|
|
458
|
-
Weitere Verwendungsbeispiele finden Sie im Verzeichnis `examples/`:
|
|
459
|
-
|
|
460
|
-
- `basic-usage.js` - Einfache Proxy-Einrichtung
|
|
461
|
-
- `advanced-usage.js` - Erweiterte Funktionen (Validierung, CORS, Remapping)
|
|
462
|
-
- `custom-handlers.js` - Benutzerdefinierte Request-Handler
|
|
463
|
-
- `docker-compose.example.yml` - Vollständige Docker-Einrichtung
|
|
464
|
-
|
|
465
|
-
## 🔐 SSL/TLS-Zertifikate
|
|
466
|
-
|
|
467
|
-
### Selbstsignierte Zertifikate generieren
|
|
278
|
+
## 🔐 SSL-Zertifikate
|
|
468
279
|
|
|
469
|
-
|
|
280
|
+
### Entwicklung (Self-Signed)
|
|
470
281
|
|
|
471
282
|
```bash
|
|
472
283
|
mkdir -p certs
|
|
473
284
|
openssl req -x509 -newkey rsa:4096 -keyout certs/key.pem -out certs/cert.pem -days 365 -nodes
|
|
474
285
|
```
|
|
475
286
|
|
|
476
|
-
### Let's Encrypt
|
|
477
|
-
|
|
478
|
-
Für die Produktion verwenden Sie Let's Encrypt-Zertifikate:
|
|
287
|
+
### Produktion (Let's Encrypt)
|
|
479
288
|
|
|
480
289
|
```bash
|
|
481
290
|
certbot certonly --standalone -d example.com
|
|
482
291
|
```
|
|
483
292
|
|
|
484
|
-
Verweisen Sie dann in Ihrer Konfiguration darauf:
|
|
485
|
-
|
|
486
|
-
```json
|
|
487
|
-
{
|
|
488
|
-
"ssl": {
|
|
489
|
-
"key": "/etc/letsencrypt/live/example.com/privkey.pem",
|
|
490
|
-
"cert": "/etc/letsencrypt/live/example.com/fullchain.pem"
|
|
491
|
-
}
|
|
492
|
-
}
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
## 🤝 Mitwirken
|
|
496
|
-
|
|
497
|
-
Beiträge sind willkommen! Bitte zögern Sie nicht, einen Pull Request einzureichen.
|
|
498
|
-
|
|
499
|
-
## 📄 Lizenz
|
|
500
|
-
|
|
501
|
-
MIT © Robiki sp. z o.o.
|
|
502
|
-
|
|
503
|
-
## 🔗 Links
|
|
504
|
-
|
|
505
|
-
- [GitHub-Repository](https://github.com/robiki-ai/robiki-proxy)
|
|
506
|
-
- [npm-Paket](https://www.npmjs.com/package/@robiki/proxy)
|
|
507
|
-
- [Issue-Tracker](https://github.com/robiki-ai/robiki-proxy/issues)
|
|
508
|
-
|
|
509
|
-
## 💡 Anwendungsfälle
|
|
510
|
-
|
|
511
|
-
- **Microservices-Architektur**: Anfragen basierend auf Domain/Pfad an verschiedene Dienste weiterleiten
|
|
512
|
-
- **Entwicklungsumgebung**: Lokaler Proxy zum Testen mehrerer Dienste
|
|
513
|
-
- **API-Gateway**: Zentraler Einstiegspunkt mit Authentifizierung und Rate Limiting
|
|
514
|
-
- **SSL-Terminierung**: SSL/TLS auf Proxy-Ebene verarbeiten
|
|
515
|
-
- **CORS-Verwaltung**: Zentralisierte CORS-Konfiguration
|
|
516
|
-
- **Load Balancing**: Verkehr auf mehrere Instanzen verteilen (mit benutzerdefinierten Handlern)
|
|
517
|
-
|
|
518
293
|
## 🛠️ Fehlerbehebung
|
|
519
294
|
|
|
520
295
|
### Debug-Modus
|
|
521
296
|
|
|
522
|
-
|
|
297
|
+
Detaillierte Protokollierung aktivieren:
|
|
523
298
|
|
|
524
299
|
```bash
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
# Oder mit Docker
|
|
300
|
+
DEBUG=true node your-script.js
|
|
301
|
+
# oder
|
|
529
302
|
docker run -e DEBUG=true robiki/proxy:latest
|
|
530
|
-
|
|
531
|
-
# Oder in docker-compose.yml
|
|
532
|
-
services:
|
|
533
|
-
proxy:
|
|
534
|
-
image: robiki/proxy:latest
|
|
535
|
-
environment:
|
|
536
|
-
- DEBUG=true
|
|
537
303
|
```
|
|
538
304
|
|
|
539
|
-
Wenn `DEBUG=true`, protokolliert der Proxy:
|
|
540
|
-
- Alle Proxy-Verbindungsversuche (REST, WebSocket, HTTP/2-Streams)
|
|
541
|
-
- Anfrage- und Antwortdetails
|
|
542
|
-
- Verbindungsfehler und Timeouts
|
|
543
|
-
- Proxy-Fehler und Client-Fehler
|
|
544
|
-
|
|
545
305
|
### Port bereits in Verwendung
|
|
546
306
|
|
|
547
|
-
Der Proxy versucht automatisch, Prozesse auf den konfigurierten Ports zu beenden. Wenn dies fehlschlägt, geben Sie die Ports manuell frei:
|
|
548
|
-
|
|
549
307
|
```bash
|
|
550
308
|
lsof -ti:443 | xargs kill -9
|
|
551
|
-
lsof -ti:8080 | xargs kill -9
|
|
552
309
|
```
|
|
553
310
|
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
Stellen Sie sicher, dass Ihre Zertifikatdateien lesbar und im richtigen Format (PEM) sind. Verwenden Sie für die Entwicklung selbstsignierte Zertifikate.
|
|
557
|
-
|
|
558
|
-
### WebSocket-Verbindungsprobleme
|
|
559
|
-
|
|
560
|
-
Stellen Sie sicher, dass Ihre WebSocket-Routen mit dem richtigen Protokoll (ws/wss) konfiguriert sind und dass der Zieldienst WebSocket-Verbindungen unterstützt.
|
|
561
|
-
|
|
562
|
-
## 🧪 Testen
|
|
563
|
-
|
|
564
|
-
Robiki Proxy enthält eine umfassende Testsuite mit Unit-Tests, Integrationstests und erweiterten Szenarien.
|
|
565
|
-
|
|
566
|
-
### Tests ausführen
|
|
311
|
+
## 🧪 Tests
|
|
567
312
|
|
|
568
313
|
```bash
|
|
569
314
|
# Alle Tests ausführen
|
|
570
315
|
yarn test
|
|
571
316
|
|
|
572
|
-
#
|
|
573
|
-
yarn test:watch
|
|
574
|
-
|
|
575
|
-
# Tests mit Coverage ausführen
|
|
317
|
+
# Mit Coverage
|
|
576
318
|
yarn test:coverage
|
|
577
319
|
|
|
578
|
-
# Tests
|
|
579
|
-
yarn test:ui
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
### Test-Coverage
|
|
583
|
-
|
|
584
|
-
Die Testsuite umfasst:
|
|
585
|
-
|
|
586
|
-
- **Unit-Tests**: Konfiguration, Utilities, Header-Konvertierung, CORS-Behandlung
|
|
587
|
-
- **Integrationstests**: HTTP-Proxying, Routenauflösung, Validierung, Config-Loading
|
|
588
|
-
- **Erweiterte Tests**: WebSocket-Proxying, HTTP/2-Streams, gleichzeitige Verbindungen
|
|
589
|
-
- **Docker-Tests**: Container-Builds, Config-Loading, Laufzeitverhalten
|
|
590
|
-
|
|
591
|
-
### Docker-Tests
|
|
592
|
-
|
|
593
|
-
Docker-Integrationstests ausführen:
|
|
594
|
-
|
|
595
|
-
```bash
|
|
596
|
-
# Vollständiger Docker-Integrationstest
|
|
320
|
+
# Docker-Tests
|
|
597
321
|
yarn test:docker
|
|
598
|
-
|
|
599
|
-
# Config-Loading spezifisch testen
|
|
600
|
-
yarn test:docker:config
|
|
601
|
-
|
|
602
|
-
# Alle Tests ausführen (Unit + Integration + Docker)
|
|
603
|
-
yarn test:all
|
|
604
322
|
```
|
|
605
323
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
```bash
|
|
609
|
-
# Schneller Docker-Build-Test
|
|
610
|
-
make test-docker
|
|
611
|
-
|
|
612
|
-
# Vollständige Integrationstestsuite
|
|
613
|
-
make test-docker-full
|
|
614
|
-
|
|
615
|
-
# Config-Loading-Test
|
|
616
|
-
make test-docker-config
|
|
324
|
+
## 📚 Beispiele
|
|
617
325
|
|
|
618
|
-
|
|
619
|
-
make test-docker-compose
|
|
620
|
-
```
|
|
326
|
+
Siehe das `examples/`-Verzeichnis:
|
|
621
327
|
|
|
622
|
-
|
|
328
|
+
- `basic-usage.js` - Einfaches Proxy-Setup
|
|
329
|
+
- `advanced-usage.js` - Validierung, CORS, Remapping
|
|
330
|
+
- `custom-handlers.js` - Benutzerdefinierte Request-Handler
|
|
331
|
+
- `docker-compose.example.yml` - Docker-Setup
|
|
623
332
|
|
|
624
|
-
##
|
|
333
|
+
## 🤝 Mitwirken
|
|
625
334
|
|
|
626
|
-
|
|
335
|
+
Beiträge willkommen! Siehe [CONTRIBUTING.md](CONTRIBUTING.md) für Details.
|
|
627
336
|
|
|
628
|
-
|
|
629
|
-
- Minimaler Overhead
|
|
630
|
-
- Connection Pooling
|
|
631
|
-
- Automatischer HTTP/1.1-Fallback
|
|
337
|
+
## 📄 Lizenz
|
|
632
338
|
|
|
633
|
-
|
|
339
|
+
MIT © Robiki sp. z o.o.
|
|
634
340
|
|
|
635
|
-
|
|
636
|
-
- Aktivierung von Clustering für Multi-Core-Systeme
|
|
637
|
-
- Überwachung mit Health Checks
|
|
638
|
-
- Einrichtung eines ordnungsgemäßen Loggings
|
|
341
|
+
## 🔗 Links
|
|
639
342
|
|
|
343
|
+
- [GitHub Repository](https://github.com/robiki-ai/robiki-proxy)
|
|
344
|
+
- [npm Package](https://www.npmjs.com/package/@robiki/proxy)
|
|
345
|
+
- [Issue Tracker](https://github.com/robiki-ai/robiki-proxy/issues)
|