Skip to content

Commit 802c4bc

Browse files
committed
handle websocket rejections correctly (hopefully)
1 parent f9bed03 commit 802c4bc

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "node-proxy-manager",
33
"fullname": "Node Proxy Manager",
4-
"version": "0.3.1",
4+
"version": "0.3.2",
55
"description": "An NodeJS alternative to Nginx Proxy Manager that is hopefully more reliable.",
66
"main": "index.js",
77
"scripts": {

proxy.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,13 +285,23 @@ const wsRequest = (req, socket, head) => {
285285
const domain = req?.headers?.host?.split(':')[0];
286286
const domConfProxy = config.proxy.find(({ host: hosts, enabled = true }) => enabled && hosts.includes(domain));
287287
if (domConfProxy && domConfProxy.websocket) {
288+
if (domConfProxy.maintenance) {
289+
socket.write('HTTP/1.1 503 Service Unavailable\r\n' +
290+
'Connection: close\r\n' +
291+
'\r\n');
292+
socket.destroy();
293+
return;
294+
}
288295
proxy.ws(req, socket, head, {
289296
target: domConfProxy.target,
290297
xfwd: true,
291298
proxyTimeout: domConfProxy.timeout || config.timeout,
292299
headers: domConfProxy.headers || {}
293300
});
294301
} else {
302+
socket.write('HTTP/1.1 403 Forbidden\r\n' +
303+
'Connection: close\r\n' +
304+
'\r\n');
295305
socket.destroy();
296306
}
297307
}

0 commit comments

Comments
 (0)