- Server operating system version
- Ubuntu 22.04.4
- Plesk version and microupdate number
- 18.0.60
I'm setting up a server on Plesk with a React.js and Node.js application, containing a client and server side.
Below the socket in my client config file:
And this is the setup on the server side:
I'm 100% sure this configuration works as I've tested it locally, as well as it's being used on another server which doesn't use Plesk.
I've set up the domains for the client and server, and when I now open my client I get the error message:
I don't now where the configuration mistake lies, I've also tried almost everything in the nginx.conf files of both the subdomain and the config file in /etc/nginx/nginx.conf for example:
and included it in the /etc/nginx/nginx.conf file. For this option I got errors if tried to place in the Additional nginx directives regarding "upstream" and "server".
Nothing seems to work and I keep getting the same error. Any suggestions help!
Below the socket in my client config file:
export const socket = io('wss://domain.name:3000', {reconnect: true, transports: [ 'websocket' ] });
And this is the setup on the server side:
JavaScript:
ServerConfig.port = 3000;
const server = this.app.listen(ServerConfig.port, () => {
console.log('Ready on port %d', server.address().port);
}),
I'm 100% sure this configuration works as I've tested it locally, as well as it's being used on another server which doesn't use Plesk.
I've set up the domains for the client and server, and when I now open my client I get the error message:
main.js:75 WebSocket connection to 'wss://domain.name:3000/socket.io/?EIO=3&transport=websocket' failed:
I don't now where the configuration mistake lies, I've also tried almost everything in the nginx.conf files of both the subdomain and the config file in /etc/nginx/nginx.conf for example:
- Added the location block in Plesk with the correct IP address and port:
NGINX:
location / {
proxy_pass http://ip.address:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
- Also tried this with a localhost IP, since both services run on the same server. (just on different subdomains and ports)
- Create a custom nginx file with the following:
NGINX:
upstream websocket {
ip_hash;
server ip.address:3000 weight=5;
keepalive 10;
}
NGINX:
server {
listen ip.address:443;
ssl_certificate /opt/psa/var/certificates/certificate;
ssl_certificate_key /opt/psa/var/certificates/key;
server_name domain.name service.domain.name;
location / {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
and included it in the /etc/nginx/nginx.conf file. For this option I got errors if tried to place in the Additional nginx directives regarding "upstream" and "server".
Nothing seems to work and I keep getting the same error. Any suggestions help!