添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
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 .

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:
proxy_pass http://mysub.domain.com:2001;
  • - ''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. Thank you so much it did help me after hours of search
  • Terms and rules
  • Privacy policy
  •