Skip to content

Commit 112435d

Browse files
committed
nginx: align webrtc/signaling proxy with SUBFOLDERwebsocket, honour SUBFOLDER
Two issues raised in review (both server blocks, :3000 and :3001): 1. The signaling regex was anchored at root: `^/webrtc/signaling/?$`. With a non-default SUBFOLDER deployment (e.g. SUBFOLDER=/foo/), the request path `/foo/webrtc/signaling/` would not match and would fall through to the static handler. Replace the leading `/` with the SUBFOLDER placeholder so the same sed substitution that processes every other location block also applies here. Default `SUBFOLDER=/` keeps the regex equivalent to before. 2. The new WebSocket location was missing the long timeouts and forwarded client headers that `SUBFOLDERwebsocket` already sets. Without them, signaling sessions can be cut by nginx defaults and selkies upstream sees only 127.0.0.1 as the client IP. Mirror the full set: X-Real-IP, X-Forwarded-For, X-Forwarded-Proto, the three 3600s timeouts, and client_max_body_size 10M. /turn gains the same forwarded headers (no timeouts — short HTTP request).
1 parent c49d8ea commit 112435d

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

root/defaults/default.conf

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,26 @@ server {
5656
# streamMode is "webrtc", and fetches /turn for TURN credentials.
5757
location SUBFOLDERturn {
5858
proxy_set_header Host $host;
59+
proxy_set_header X-Real-IP $remote_addr;
60+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
61+
proxy_set_header X-Forwarded-Proto $scheme;
5962
proxy_http_version 1.1;
6063
proxy_buffering off;
6164
proxy_pass http://127.0.0.1:CWS;
6265
}
63-
location ~ ^/webrtc/signaling/?$ {
66+
location ~ ^SUBFOLDERwebrtc/signaling/?$ {
6467
proxy_set_header Upgrade $http_upgrade;
6568
proxy_set_header Connection "upgrade";
6669
proxy_set_header Host $host;
70+
proxy_set_header X-Real-IP $remote_addr;
71+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
72+
proxy_set_header X-Forwarded-Proto $scheme;
6773
proxy_http_version 1.1;
74+
proxy_read_timeout 3600s;
75+
proxy_send_timeout 3600s;
76+
proxy_connect_timeout 3600s;
6877
proxy_buffering off;
78+
client_max_body_size 10M;
6979
proxy_pass http://127.0.0.1:CWS;
7080
}
7181
error_page 500 502 503 504 /50x.html;
@@ -134,16 +144,26 @@ server {
134144
# streamMode is "webrtc", and fetches /turn for TURN credentials.
135145
location SUBFOLDERturn {
136146
proxy_set_header Host $host;
147+
proxy_set_header X-Real-IP $remote_addr;
148+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
149+
proxy_set_header X-Forwarded-Proto $scheme;
137150
proxy_http_version 1.1;
138151
proxy_buffering off;
139152
proxy_pass http://127.0.0.1:CWS;
140153
}
141-
location ~ ^/webrtc/signaling/?$ {
154+
location ~ ^SUBFOLDERwebrtc/signaling/?$ {
142155
proxy_set_header Upgrade $http_upgrade;
143156
proxy_set_header Connection "upgrade";
144157
proxy_set_header Host $host;
158+
proxy_set_header X-Real-IP $remote_addr;
159+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
160+
proxy_set_header X-Forwarded-Proto $scheme;
145161
proxy_http_version 1.1;
162+
proxy_read_timeout 3600s;
163+
proxy_send_timeout 3600s;
164+
proxy_connect_timeout 3600s;
146165
proxy_buffering off;
166+
client_max_body_size 10M;
147167
proxy_pass http://127.0.0.1:CWS;
148168
}
149169
error_page 500 502 503 504 /50x.html;

0 commit comments

Comments
 (0)