dynamic-self-register-proxy 1.0.14 → 1.0.16
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.md +27 -1
- package/package.json +2 -1
- package/proxy.js +10 -3
package/README.md
CHANGED
|
@@ -38,7 +38,18 @@ dynamic-proxy
|
|
|
38
38
|
npm start
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
Le proxy démarre par défaut sur le port `3000`.
|
|
41
|
+
Le proxy démarre par défaut sur le port `3000`.
|
|
42
|
+
|
|
43
|
+
### Configuration via fichier .env
|
|
44
|
+
|
|
45
|
+
Créez un fichier `.env` à la racine du projet (voir `.env.example`) :
|
|
46
|
+
|
|
47
|
+
```env
|
|
48
|
+
PROXY_NAME=Mon Proxy Dev
|
|
49
|
+
PROXY_PORT=3000
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Configuration via variables d'environnement
|
|
42
53
|
|
|
43
54
|
```bash
|
|
44
55
|
# Windows PowerShell
|
|
@@ -79,6 +90,8 @@ http://localhost:3000/myapp/ → votre application sur le port 4000
|
|
|
79
90
|
|
|
80
91
|
L'URL racine `/` affiche une page listant tous les serveurs enregistrés avec des liens pour y accéder.
|
|
81
92
|
|
|
93
|
+
Le nom du proxy (configurable via `PROXY_NAME`) est affiché dans le titre et l'en-tête de la page.
|
|
94
|
+
|
|
82
95
|
- **Navigateurs** (`Accept: text/html`) → Page HTML avec interface moderne
|
|
83
96
|
- **Clients API** (`Accept: application/json`) → Réponse JSON
|
|
84
97
|
|
|
@@ -92,6 +105,7 @@ curl -H "Accept: application/json" http://localhost:3000/
|
|
|
92
105
|
**Réponse JSON :**
|
|
93
106
|
```json
|
|
94
107
|
{
|
|
108
|
+
"name": "Proxy Server",
|
|
95
109
|
"status": "healthy",
|
|
96
110
|
"uptime": 3600,
|
|
97
111
|
"count": 2,
|
|
@@ -207,6 +221,7 @@ Vérifie l'état du proxy.
|
|
|
207
221
|
**Response:**
|
|
208
222
|
```json
|
|
209
223
|
{
|
|
224
|
+
"name": "Proxy Server",
|
|
210
225
|
"status": "healthy",
|
|
211
226
|
"uptime": 3600,
|
|
212
227
|
"registeredRoutes": 2,
|
|
@@ -421,6 +436,7 @@ Dans votre fichier de configuration Claude Desktop (`claude_desktop_config.json`
|
|
|
421
436
|
"command": "npx",
|
|
422
437
|
"args": ["dynamic-self-register-proxy"],
|
|
423
438
|
"env": {
|
|
439
|
+
"PROXY_NAME": "MCP Gateway",
|
|
424
440
|
"PROXY_PORT": "8080",
|
|
425
441
|
"HEALTH_CHECK_INTERVAL": "60000",
|
|
426
442
|
"HEALTH_CHECK_TIMEOUT": "10000",
|
|
@@ -433,12 +449,22 @@ Dans votre fichier de configuration Claude Desktop (`claude_desktop_config.json`
|
|
|
433
449
|
|
|
434
450
|
## Configuration
|
|
435
451
|
|
|
452
|
+
Le proxy charge automatiquement le fichier `.env` s'il existe (voir `.env.example` pour un template).
|
|
453
|
+
|
|
454
|
+
### Variables du proxy
|
|
455
|
+
|
|
436
456
|
| Variable | Défaut | Description |
|
|
437
457
|
|----------|--------|-------------|
|
|
458
|
+
| `PROXY_NAME` | `Proxy Server` | Nom affiché sur la page d'accueil |
|
|
438
459
|
| `PROXY_PORT` | `3000` | Port d'écoute du proxy |
|
|
439
460
|
| `HEALTH_CHECK_INTERVAL` | `30000` | Intervalle du health check polling (ms) |
|
|
440
461
|
| `HEALTH_CHECK_TIMEOUT` | `5000` | Timeout pour chaque health check (ms) |
|
|
441
462
|
| `HEALTH_CHECK_GRACE_PERIOD` | `60000` | Période de grâce pour les nouveaux serveurs (ms) |
|
|
463
|
+
|
|
464
|
+
### Variables pour les applications clientes
|
|
465
|
+
|
|
466
|
+
| Variable | Défaut | Description |
|
|
467
|
+
|----------|--------|-------------|
|
|
442
468
|
| `PROXY_URL` | `http://localhost:3000` | URL du proxy (pour les apps) |
|
|
443
469
|
| `APP_PATH` | `/example` | Chemin de l'application |
|
|
444
470
|
| `APP_NAME` | `Example App` | Nom de l'application |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dynamic-self-register-proxy",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "Dynamic reverse proxy with self-registration API - applications can register themselves and receive an automatically assigned port",
|
|
5
5
|
"main": "proxy-client.js",
|
|
6
6
|
"bin": {
|
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
"node": ">=18.0.0"
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
+
"dotenv": "^17.2.3",
|
|
56
57
|
"express": "^5.2.1",
|
|
57
58
|
"http-proxy-middleware": "^3.0.5"
|
|
58
59
|
}
|
package/proxy.js
CHANGED
|
@@ -4,6 +4,10 @@ const express = require('express');
|
|
|
4
4
|
const { createProxyMiddleware } = require('http-proxy-middleware');
|
|
5
5
|
const { setupLogging } = require('./logger');
|
|
6
6
|
const { execSync } = require('child_process');
|
|
7
|
+
const path = require('path');
|
|
8
|
+
|
|
9
|
+
// Chargement du fichier .env depuis le répertoire du script
|
|
10
|
+
require('dotenv').config({ path: path.join(__dirname, '.env') });
|
|
7
11
|
|
|
8
12
|
// Initialisation du logging
|
|
9
13
|
setupLogging('PROXY');
|
|
@@ -15,6 +19,7 @@ app.use(express.json());
|
|
|
15
19
|
// CONFIGURATION
|
|
16
20
|
// ============================================
|
|
17
21
|
const PROXY_PORT = process.env.PROXY_PORT || 3000;
|
|
22
|
+
const PROXY_NAME = process.env.PROXY_NAME || 'Proxy Server';
|
|
18
23
|
const INTERNAL_PORT_START = 4000;
|
|
19
24
|
const INTERNAL_PORT_END = 5000;
|
|
20
25
|
const HEALTH_CHECK_INTERVAL = process.env.HEALTH_CHECK_INTERVAL || 30000; // 30 secondes par défaut
|
|
@@ -511,6 +516,7 @@ app.post('/proxy/check', async (req, res) => {
|
|
|
511
516
|
*/
|
|
512
517
|
app.get('/proxy/health', (req, res) => {
|
|
513
518
|
res.json({
|
|
519
|
+
name: PROXY_NAME,
|
|
514
520
|
status: 'healthy',
|
|
515
521
|
uptime: process.uptime(),
|
|
516
522
|
registeredRoutes: registry.routes.size,
|
|
@@ -547,6 +553,7 @@ app.get('/', (req, res) => {
|
|
|
547
553
|
|
|
548
554
|
if (wantsJson) {
|
|
549
555
|
return res.json({
|
|
556
|
+
name: PROXY_NAME,
|
|
550
557
|
status: 'healthy',
|
|
551
558
|
uptime: process.uptime(),
|
|
552
559
|
count: routes.length,
|
|
@@ -561,7 +568,7 @@ app.get('/', (req, res) => {
|
|
|
561
568
|
<head>
|
|
562
569
|
<meta charset="UTF-8">
|
|
563
570
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
564
|
-
<title
|
|
571
|
+
<title>${escapeHtml(PROXY_NAME)} - Services disponibles</title>
|
|
565
572
|
<style>
|
|
566
573
|
* {
|
|
567
574
|
margin: 0;
|
|
@@ -896,7 +903,7 @@ app.get('/', (req, res) => {
|
|
|
896
903
|
<body>
|
|
897
904
|
<div class="container">
|
|
898
905
|
<header>
|
|
899
|
-
<h1>🚀
|
|
906
|
+
<h1>🚀 ${escapeHtml(PROXY_NAME)}</h1>
|
|
900
907
|
<p class="subtitle">Services disponibles</p>
|
|
901
908
|
<div class="stats">
|
|
902
909
|
<div class="stat">
|
|
@@ -1226,7 +1233,7 @@ app.use((req, res, next) => {
|
|
|
1226
1233
|
|
|
1227
1234
|
app.listen(PROXY_PORT, () => {
|
|
1228
1235
|
console.log('='.repeat(50));
|
|
1229
|
-
console.log(
|
|
1236
|
+
console.log(`🚀 ${PROXY_NAME}`);
|
|
1230
1237
|
console.log('='.repeat(50));
|
|
1231
1238
|
console.log(`Listening on port ${PROXY_PORT}`);
|
|
1232
1239
|
console.log(`Internal ports range: ${INTERNAL_PORT_START}-${INTERNAL_PORT_END}`);
|