Please be aware: Kaspersky Anti-Virus has been deprecated and is no longer available for installation on the current Plesk release
(18.0.63).Starting from Plesk Obsidian 18.0.64, the extension will be automatically removed from the servers it is installed on. For details and recommended actions, see
the Feature and Deprecation Plan
and
the deprecation FAQ
.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Resolved
Nginx WebSocket Connection as Secure Problem
But I want to use this connection websocket connection on
SSL - https://
schema. At at time, I get connection error like this.
Proxy mode is on:
Screenshot
PHP works with NGINX, see:
Screenshot
What I tried:
I added this block to /..vhosts/domain.com/mysub.domain.com/conf/nginx/nginx.conf
Code:
location ~ /WsConn
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://mysub.domain.com:2001;
Then, I tried to connection on SSL schema,
Code:
var conn = new WebSocket('wss://my.domain.com/WsConn');
And when you connect directly to wss://mysub.domain.com:2001, does it work? Did you configure that backend to use SSL? (Reminder that you can only use unencrypted or SSL on each port, sharing is only possible with STARTTLS which does not help here.)
If you wanted to use nginx to add SSL to the websocket because it can not use SSL on its own, then the connection from nginx to the backend must use http, not https, i.e.
NGINX:
proxy_pass http://mysub.domain.com:2001;
And when you connect directly to wss://mysub.domain.com:2001, does it work? Did you configure that backend to use SSL? (Reminder that you can only use unencrypted or SSL on each port, sharing is only possible with STARTTLS which does not help here.)
If you wanted to use nginx to add SSL to the websocket because it can not use SSL on its own, then the connection from nginx to the backend must use http, not https, i.e.
NGINX:
- ''when you connect directly to wss://mysub.domain.com:2001, does it work?''
+ yeap, it does not work.
and yes, domain has an SSL connection, it works well as https:// schema.
- ''If you wanted to use nginx to add SSL to the websocket because it can not use SSL on its own, then the connection from nginx to the backend must use http, not https, i.e.''
+ hmm maybe I, missed it, don't remebber.
fortunately, I solved this issue like that:
Go to Plesk Admin, my domain hosting settings -> Apache & nginx Settings
Paste this block to Additional Nginx Directives:
Code:
location ~ /WsConn
proxy_pass http://127.0.0.1:2001;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
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;
maybe it helps to someone.
thank you for your answer.
- ''when you connect directly to wss://mysub.domain.com:2001, does it work?''
+ yeap, it does not work.
and yes, domain has an SSL connection, it works well as https:// schema.
- ''If you wanted to use nginx to add SSL to the websocket because it can not use SSL on its own, then the connection from nginx to the backend must use http, not https, i.e.''
+ hmm maybe I, missed it, don't remebber.
fortunately, I solved this issue like that:
Go to Plesk Admin, my domain hosting settings -> Apache & nginx Settings
Paste this block to Additional Nginx Directives:
Code:
location ~ /WsConn
proxy_pass http://127.0.0.1:2001;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
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;
maybe it helps to someone.
thank you for your answer.