Skip to content

Commit 635780e

Browse files
committed
Fix nginx configuration for panel routing
Critical fixes based on backend dev feedback: 1. Add trailing slash to proxy_pass to strip /panel/ prefix properly 2. Add required proxy headers for proper request forwarding Before: /panel/login → http://127.0.0.1:9002/panel/login (broken) After: /panel/login → http://127.0.0.1:9002/login (correct) This fixes panel accessibility at https://domain.com/panel/
1 parent 41bb5d5 commit 635780e

2 files changed

Lines changed: 97 additions & 1 deletion

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,11 @@ server {
288288
}
289289
290290
location /panel/ {
291-
proxy_pass http://127.0.0.1:9002;
291+
proxy_pass http://127.0.0.1:9002/;
292+
proxy_set_header Host $host;
293+
proxy_set_header X-Real-IP $remote_addr;
294+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
295+
proxy_set_header X-Forwarded-Proto $scheme;
292296
}
293297
294298
# Default location - Relay service with WebSocket support

fixed_nginx_config.conf

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Define upstream servers for each service (using explicit IPv4 addresses)
2+
upstream transcribe_api {
3+
server 127.0.0.1:8000;
4+
}
5+
6+
upstream relay_service {
7+
server 127.0.0.1:9001;
8+
}
9+
10+
upstream panel_service {
11+
server 127.0.0.1:9002;
12+
}
13+
14+
upstream wallet_service {
15+
server 127.0.0.1:9003;
16+
}
17+
18+
# WebSocket connection upgrade mapping
19+
map $http_upgrade $connection_upgrade {
20+
default upgrade;
21+
'' close;
22+
}
23+
24+
# Main server block listening on HTTP
25+
server {
26+
listen 80; # Nginx listens on port 80 locally
27+
server_name localhost *.serveo.net _; # Dynamic - works with any serveo URL and localhost
28+
29+
# Basic Security Headers
30+
add_header X-Frame-Options "SAMEORIGIN";
31+
add_header X-Content-Type-Options "nosniff";
32+
add_header X-XSS-Protection "1; mode=block";
33+
server_tokens off;
34+
35+
# Forward client IP and protocol
36+
proxy_set_header X-Real-IP $remote_addr;
37+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
38+
proxy_set_header X-Forwarded-Proto $scheme;
39+
proxy_set_header Host $host;
40+
41+
location /transcribe/ {
42+
rewrite ^/transcribe/(.*)$ /$1 break;
43+
proxy_pass http://transcribe_api;
44+
}
45+
46+
# Panel access - Admin dashboard (FIXED: proper trailing slash and headers)
47+
location /panel {
48+
return 301 /panel/;
49+
}
50+
51+
location /panel/ {
52+
proxy_pass http://panel_service/;
53+
proxy_set_header Host $host;
54+
proxy_set_header X-Real-IP $remote_addr;
55+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
56+
proxy_set_header X-Forwarded-Proto $scheme;
57+
}
58+
59+
location /wallet/ {
60+
rewrite ^/wallet/(.*)$ /$1 break;
61+
proxy_pass http://wallet_service;
62+
}
63+
64+
# Health check endpoint
65+
location /health {
66+
access_log off;
67+
return 200 "healthy\n";
68+
add_header Content-Type text/plain;
69+
}
70+
71+
# Default location - Relay service with WebSocket support
72+
location / {
73+
proxy_pass http://relay_service;
74+
75+
# WebSocket-specific headers
76+
proxy_http_version 1.1;
77+
proxy_set_header Upgrade $http_upgrade;
78+
proxy_set_header Connection $connection_upgrade;
79+
proxy_set_header Host $host;
80+
proxy_cache_bypass $http_upgrade;
81+
82+
# Extended timeouts for WebSocket connections
83+
proxy_read_timeout 86400s;
84+
proxy_send_timeout 86400s;
85+
proxy_connect_timeout 60s;
86+
87+
# Additional headers for tunnel compatibility
88+
proxy_set_header X-Forwarded-Proto $scheme;
89+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
90+
proxy_set_header X-Real-IP $remote_addr;
91+
}
92+
}

0 commit comments

Comments
 (0)