I'm trying to proxy socket.example.com:4000
to a websocket server mydomain.com:3000
but the client can also connect to the server through *.example.com:4000
, It's like vhost
has no effect and the proxy configuration is set globally. I don't want other subdomains be proxied.
i use vhost and http-proxy-middleware
const options = {
target: 'http://example.com:3000',
changeOrigin: true,
ws: true
};
const wsProxy = createProxyMiddleware(options);
app.use(vhost('socket.example.com', wsProxy));