-
Checks
Describe the bug (be clear and concise)I have an instance of ttyd that is already reverse proxied by nginx at the URL This is how I create the proxy: const ttydProxy = createProxyMiddleware({
target: `https://192.168.1.1:4443/ttyd`,
changeOrigin: true,
ws: true,
secure: false,
logLevel: 'silent',
pathRewrite: {
'^/ttyd': ''
},
onProxyReq: fixRequestBody
}) And I use it with the express app like this: app.use(['/ttyd', '/ttyd/*'], [ensureAuthenticated, ttydProxy]) Everything works well, atleast for a few minutes i.e before my browser starts showing this in the console with the iframe in question: I'm not sure if it's something to do with my setup or something else entirely, would love some pointers in the right direction if it is indeed my fault Step-by-step reproduction instructionsTry with the config I've mentioned in the description that should be able to reproduce the issue Expected behavior (be clear and concise)Websocket should be able to connect even after a long period of inactivity How is http-proxy-middleware used in your project?[email protected] /www/app
`-- [email protected] What http-proxy-middleware configuration are you using?const ttydProxy = createProxyMiddleware({
target: `https://192.168.1.1:4443/ttyd`,
changeOrigin: true,
ws: true,
secure: false,
logLevel: 'silent',
pathRewrite: {
'^/ttyd': ''
},
onProxyReq: fixRequestBody
}) What OS/version and node/version are you seeing the problem?OpenWRT Linux 22.04, NodeJS v16.17.1 Additional context (optional)No response |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 1 reply
-
If you think it's an bug; Can you provide a minimal working reproduction? |
Beta Was this translation helpful? Give feedback.
-
https://codesandbox.io/s/http-proxy-middleware-forked-w6fvni?file=/src/index.js I've made a sandbox here but I'm not sure when the actual disconnection occurs or if the sandbox will be able to catch it because it looks like the sandbox "server" reboots every now and then? So the issue is that when my express app starts up it is able to connect and I'm able to use ttyd well through the reverse proxy but after a while, the wss part just throws a 404 even though it was working for a while |
Beta Was this translation helpful? Give feedback.
-
This is my setup now, I simplified it to just one route which is /ttyd const ttydProxy = createProxyMiddleware({
target: `https://${getLocalIP()}:4443/ttyd`,
changeOrigin: true,
ws: true,
secure: false,
logLevel: 'debug',
pathRewrite: {
'^/ttyd': ''
},
onProxyReq: function(proxyReq, req, res) {
//console.log('path', req.path)
console.log('url', req.url)
}
}) app.use('/ttyd', [ensureAuthenticated, ttydProxy]) Then I initialize the express app using spdy.createServer(sslOptions, app).listen(PORT, () => {
logger.info(`app server listening on port ${PORT}`)
}); I have a bunch of other stuff in EDIT: it did stop working again and I see these in my syslogs:
|
Beta Was this translation helpful? Give feedback.
-
I fixed it by removing |
Beta Was this translation helpful? Give feedback.
I fixed it by removing
ws:true
from the other reverse proxies I was having, now only the ttyd proxy hasws:true
if anyone else comes across this issue in the future, I'm not really sure why this happens, but it works for me now