Skip to content

Commit dd81811

Browse files
Merge pull request #62 from HORNET-Storage/feature/optional-wallet-configuration
Feature/optional wallet configuration
2 parents 1fa88c6 + d22bb12 commit dd81811

File tree

29 files changed

+853
-849
lines changed

29 files changed

+853
-849
lines changed

.env.development

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ REACT_APP_ASSETS_BUCKET=http://localhost
44
REACT_APP_DEMO_MODE=false
55
REACT_APP_BASENAME=
66

7-
# Nostr relay configuration for profile fetching
8-
REACT_APP_OWN_RELAY_URL=ws://localhost:9001
9-
# REACT_APP_NOSTR_RELAY_URLS=wss://your-relay1.com,wss://your-relay2.com,wss://your-relay3.com
7+
# Nostr operations now use panel API - no relay URLs needed
108

119
# More info https://create-react-app.dev/docs/advanced-configuration
1210
ESLINT_NO_DEV_ERRORS=true

.env.production

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@
44
# Demo mode (set to false for production)
55
REACT_APP_DEMO_MODE=false
66

7-
# Direct wallet service access
8-
REACT_APP_WALLET_BASE_URL=
7+
# Wallet operations now routed through panel API - no direct URL needed
98

109
# Router configuration (empty since served from relay server root)
1110
REACT_APP_BASENAME=
12-
PUBLIC_URL=
11+
PUBLIC_URL=/
1312

1413
# Asset serving configuration (optional - adjust for your domain)
1514
# REACT_APP_ASSETS_BUCKET=https://your-domain.com
1615

17-
# Nostr relay configuration for profile fetching
18-
REACT_APP_OWN_RELAY_URL=ws://localhost:9001
19-
# REACT_APP_NOSTR_RELAY_URLS=wss://your-relay1.com,wss://your-relay2.com
16+
# Nostr operations now use panel API - no relay URLs needed
2017

2118
# Development optimizations
2219
ESLINT_NO_DEV_ERRORS=true

.env.production.example

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ PUBLIC_URL=/panel
1111
# Asset serving configuration (optional - adjust for your domain)
1212
# REACT_APP_ASSETS_BUCKET=https://your-domain.com
1313

14-
# Nostr relay configuration for profile fetching
15-
# REACT_APP_OWN_RELAY_URL= # ✅ Auto-detected from current domain
16-
# REACT_APP_NOSTR_RELAY_URLS=wss://your-relay1.com,wss://your-relay2.com
14+
# Nostr operations now use panel API - no relay URLs needed
1715

1816
# Development optimizations
1917
ESLINT_NO_DEV_ERRORS=true

README.md

Lines changed: 133 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,132 @@ For development, you can run services directly:
111111

112112
### Nginx Proxy (Production Recommended)
113113
For production deployment, nginx handles:
114-
1. **Wallet Service Proxying**: `/wallet/*``localhost:9003`
115-
2. **SSL Termination**: Single certificate for entire application
116-
3. **WebSocket Proxying**: Proper upgrade headers for relay WebSocket
117-
4. **Static Asset Caching**: Optimal performance for React app
118-
5. **Security Headers**: CORS, CSP, and other protections
114+
1. **Relay WebSocket Proxying**: `/relay` and `/relay/``localhost:9001` (strips prefix)
115+
2. **Wallet Service Proxying**: `/wallet/*``localhost:9003`
116+
3. **SSL Termination**: Single certificate for entire application
117+
4. **WebSocket Proxying**: Proper upgrade headers for relay WebSocket
118+
5. **Static Asset Caching**: Optimal performance for React app
119+
6. **Security Headers**: CORS, CSP, and other protections
120+
121+
#### Complete Working Nginx Configuration
122+
Here's a complete working nginx configuration for the HORNETS Relay Panel (tested on macOS and Linux):
123+
124+
```nginx
125+
# Define upstream servers for each service (using explicit IPv4 addresses)
126+
upstream transcribe_api {
127+
server 127.0.0.1:8000;
128+
}
129+
130+
upstream relay_service {
131+
server 127.0.0.1:9001;
132+
}
133+
134+
upstream panel_service {
135+
server 127.0.0.1:9002;
136+
}
137+
138+
upstream wallet_service {
139+
server 127.0.0.1:9003;
140+
}
141+
142+
# WebSocket connection upgrade mapping
143+
map $http_upgrade $connection_upgrade {
144+
default upgrade;
145+
'' close;
146+
}
147+
148+
# Main server block listening on HTTP
149+
server {
150+
listen 80; # Nginx listens on port 80 locally
151+
server_name _; # Accept all hostnames (localhost, ngrok, custom domains, etc.)
152+
153+
# Basic Security Headers
154+
add_header X-Frame-Options "SAMEORIGIN";
155+
add_header X-Content-Type-Options "nosniff";
156+
add_header X-XSS-Protection "1; mode=block";
157+
server_tokens off;
158+
159+
# Increase buffer sizes for large files
160+
client_max_body_size 100M;
161+
162+
# Forward client IP and protocol
163+
proxy_set_header X-Real-IP $remote_addr;
164+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
165+
proxy_set_header X-Forwarded-Proto $scheme;
166+
proxy_set_header Host $host;
167+
168+
# Health check endpoint - exact match first
169+
location = /health {
170+
access_log off;
171+
return 200 "healthy\n";
172+
add_header Content-Type text/plain;
173+
}
174+
175+
# Relay WebSocket service - handle both /relay and /relay/
176+
location ~ ^/relay/?$ {
177+
# Strip the /relay prefix (with or without trailing slash) when forwarding to the service
178+
rewrite ^/relay/?$ / break;
179+
180+
proxy_pass http://relay_service;
181+
182+
# WebSocket-specific headers
183+
proxy_http_version 1.1;
184+
proxy_set_header Upgrade $http_upgrade;
185+
proxy_set_header Connection $connection_upgrade;
186+
proxy_set_header Host $host;
187+
proxy_cache_bypass $http_upgrade;
188+
189+
# Extended timeouts for WebSocket connections
190+
proxy_read_timeout 86400s;
191+
proxy_send_timeout 86400s;
192+
proxy_connect_timeout 60s;
193+
194+
# Additional headers for tunnel compatibility
195+
proxy_set_header X-Forwarded-Proto $scheme;
196+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
197+
proxy_set_header X-Real-IP $remote_addr;
198+
}
199+
200+
# Transcribe service
201+
location /transcribe/ {
202+
rewrite ^/transcribe/(.*)$ /$1 break;
203+
proxy_pass http://transcribe_api;
204+
}
205+
206+
# Wallet service
207+
location /wallet/ {
208+
rewrite ^/wallet/(.*)$ /$1 break;
209+
proxy_pass http://wallet_service;
210+
}
211+
212+
# Default location - Panel service (frontend + API) - MUST BE LAST
213+
location / {
214+
proxy_pass http://panel_service;
215+
proxy_set_header Host $host;
216+
proxy_set_header X-Real-IP $remote_addr;
217+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
218+
proxy_set_header X-Forwarded-Proto $scheme;
219+
220+
# Handle WebSocket if needed
221+
proxy_http_version 1.1;
222+
proxy_set_header Upgrade $http_upgrade;
223+
proxy_set_header Connection $connection_upgrade;
224+
}
225+
}
226+
```
227+
228+
**Key Configuration Details:**
229+
- **Relay WebSocket**: Uses regex matching `^/relay/?$` to handle both `/relay` and `/relay/` paths
230+
- **Rewrite Rule**: Strips the `/relay` prefix before forwarding to the relay service at port 9001
231+
- **WebSocket Support**: Proper upgrade headers and extended timeouts for WebSocket connections
232+
- **Service Routing**: Panel (root), wallet (`/wallet/`), transcribe (`/transcribe/`), and relay (`/relay`)
233+
- **Security**: Basic security headers and proper client IP forwarding
234+
235+
**Deployment Steps:**
236+
1. Save this configuration to `/etc/nginx/sites-available/hornets` (or `/opt/homebrew/etc/nginx/conf.d/hornets.conf` on macOS)
237+
2. Enable the site: `sudo ln -s /etc/nginx/sites-available/hornets /etc/nginx/sites-enabled/`
238+
3. Test configuration: `sudo nginx -t`
239+
4. Reload nginx: `sudo nginx -s reload`
119240

120241
## 📋 Prerequisites
121242

@@ -157,9 +278,7 @@ REACT_APP_ASSETS_BUCKET=http://localhost
157278
REACT_APP_DEMO_MODE=false
158279
REACT_APP_BASENAME=
159280
160-
# Nostr relay configuration for profile fetching
161-
REACT_APP_OWN_RELAY_URL=ws://localhost:9001
162-
# REACT_APP_NOSTR_RELAY_URLS=wss://your-relay1.com,wss://your-relay2.com,wss://your-relay3.com
281+
# Nostr operations now use panel API - no relay URLs needed
163282
164283
# More info https://create-react-app.dev/docs/advanced-configuration
165284
ESLINT_NO_DEV_ERRORS=true
@@ -176,15 +295,13 @@ Create `.env.production` for production builds:
176295
REACT_APP_DEMO_MODE=false
177296
178297
# Service URLs
179-
REACT_APP_WALLET_BASE_URL=http://localhost:9003 # Optional - leave empty to disable wallet features
180-
REACT_APP_OWN_RELAY_URL=ws://localhost:9001 # Required for profile fetching
298+
# REACT_APP_WALLET_BASE_URL - No longer needed! Wallet operations routed through panel API
181299
182300
# Router configuration (empty for direct access)
183301
REACT_APP_BASENAME=
184302
PUBLIC_URL=
185303
186-
# Optional: Custom Nostr relay URLs (comma-separated list)
187-
# REACT_APP_NOSTR_RELAY_URLS=wss://your-relay1.com,wss://your-relay2.com
304+
# Nostr operations now use panel API - no relay URLs needed
188305
189306
# Development optimizations
190307
ESLINT_NO_DEV_ERRORS=true
@@ -193,10 +310,9 @@ TSC_COMPILE_ON_ERROR=true
193310

194311

195312
**🎯 Key Requirements**:
196-
-**Relay URL Required** - REACT_APP_OWN_RELAY_URL must be configured for profile fetching
197-
-**Wallet URL Optional** - REACT_APP_WALLET_BASE_URL can be empty to disable wallet features
313+
-**Wallet Always Available** - Wallet operations routed through panel API, no configuration needed
198314
-**Panel Routing Auto-Detection** - Panel paths (REACT_APP_BASENAME/PUBLIC_URL) can be auto-detected
199-
-**Build-Time Configuration** - Service URLs are baked into the JavaScript bundle during build
315+
-**Simplified Configuration** - Uses default Nostr relay URLs, no custom configuration needed
200316
-**Simple Deployment** - No reverse proxy needed for basic functionality
201317

202318
### 4. Start Development Server
@@ -264,16 +380,13 @@ Controls the React app's routing base path:
264380

265381
### Service URLs
266382
**🎯 Configuration Requirements**:
267-
- **Wallet Service**: `REACT_APP_WALLET_BASE_URL=http://localhost:9003` (optional - leave empty to disable wallet features)
268-
- **Relay WebSocket**: `REACT_APP_OWN_RELAY_URL=ws://localhost:9001` (required for profile fetching)
383+
- **Wallet Service**: No longer requires configuration! Wallet operations are routed through panel API (`/api/wallet-proxy/*`)
269384
- **Panel API**: Auto-detected from current origin (no configuration needed)
270385

271-
**Note**: When wallet URL is not configured, send/receive buttons will show a helpful message about rebuilding with wallet configuration.
386+
**✅ Simplified**: Wallet functionality is now always available through the panel's backend proxy.
272387

273388
**Manual Override** (development only):
274389
- **REACT_APP_BASE_URL**: Panel API endpoint (dev mode only)
275-
- **REACT_APP_WALLET_BASE_URL**: Wallet service endpoint (dev mode only)
276-
- **REACT_APP_NOSTR_RELAY_URLS**: Additional Nostr relays (optional)
277390

278391
### Demo Mode
279392
Set `REACT_APP_DEMO_MODE=true` to enable demo functionality with mock data.

craco.config.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,28 @@ module.exports = {
1616
include: /node_modules/,
1717
type: 'javascript/auto',
1818
});
19+
20+
// Split chunks to avoid large files that cause ngrok issues
21+
webpackConfig.optimization = {
22+
...webpackConfig.optimization,
23+
splitChunks: {
24+
chunks: 'all',
25+
cacheGroups: {
26+
vendor: {
27+
test: /[\\/]node_modules[\\/]/,
28+
name: 'vendors',
29+
chunks: 'all',
30+
maxSize: 1024 * 1024, // 1MB max chunk size
31+
},
32+
common: {
33+
minChunks: 2,
34+
chunks: 'all',
35+
maxSize: 1024 * 1024, // 1MB max chunk size
36+
},
37+
},
38+
},
39+
};
40+
1941
return webpackConfig;
2042
},
2143
plugins: [

fixed_nginx_config.conf

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,41 +32,27 @@ server {
3232
add_header X-XSS-Protection "1; mode=block";
3333
server_tokens off;
3434

35+
# Increase buffer sizes for large files
36+
client_max_body_size 100M;
37+
3538
# Forward client IP and protocol
3639
proxy_set_header X-Real-IP $remote_addr;
3740
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
3841
proxy_set_header X-Forwarded-Proto $scheme;
3942
proxy_set_header Host $host;
4043

41-
location /transcribe/ {
42-
rewrite ^/transcribe/(.*)$ /$1 break;
43-
proxy_pass http://transcribe_api;
44-
}
45-
46-
# Panel access - Admin dashboard (back to working rewrite pattern)
47-
location /panel/ {
48-
rewrite ^/panel/(.*)$ /$1 break;
49-
proxy_pass http://panel_service;
50-
proxy_set_header Host $host;
51-
proxy_set_header X-Real-IP $remote_addr;
52-
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
53-
proxy_set_header X-Forwarded-Proto $scheme;
54-
}
55-
56-
location /wallet/ {
57-
rewrite ^/wallet/(.*)$ /$1 break;
58-
proxy_pass http://wallet_service;
59-
}
60-
61-
# Health check endpoint
62-
location /health {
44+
# Health check endpoint - exact match first
45+
location = /health {
6346
access_log off;
6447
return 200 "healthy\n";
6548
add_header Content-Type text/plain;
6649
}
6750

68-
# Default location - Relay service with WebSocket support
69-
location / {
51+
# Relay WebSocket service - handle both /relay and /relay/
52+
location ~ ^/relay/?$ {
53+
# Strip the /relay prefix (with or without trailing slash) when forwarding to the service
54+
rewrite ^/relay/?$ / break;
55+
7056
proxy_pass http://relay_service;
7157

7258
# WebSocket-specific headers
@@ -86,4 +72,30 @@ server {
8672
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
8773
proxy_set_header X-Real-IP $remote_addr;
8874
}
75+
76+
# Transcribe service
77+
location /transcribe/ {
78+
rewrite ^/transcribe/(.*)$ /$1 break;
79+
proxy_pass http://transcribe_api;
80+
}
81+
82+
# Wallet service
83+
location /wallet/ {
84+
rewrite ^/wallet/(.*)$ /$1 break;
85+
proxy_pass http://wallet_service;
86+
}
87+
88+
# Default location - Panel service (frontend + API) - MUST BE LAST
89+
location / {
90+
proxy_pass http://panel_service;
91+
proxy_set_header Host $host;
92+
proxy_set_header X-Real-IP $remote_addr;
93+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
94+
proxy_set_header X-Forwarded-Proto $scheme;
95+
96+
# Handle WebSocket if needed
97+
proxy_http_version 1.1;
98+
proxy_set_header Upgrade $http_upgrade;
99+
proxy_set_header Connection $connection_upgrade;
100+
}
89101
}

public/logo-dark-192.png

-6.73 KB
Loading

public/logo-dark-512.png

-67.6 KB
Loading

0 commit comments

Comments
 (0)