AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1015277
Accepted
Dominique
Dominique
Asked: 2020-05-03 00:32:47 +0800 CST2020-05-03 00:32:47 +0800 CST 2020-05-03 00:32:47 +0800 CST

如何解决 Nginx WebSocket 安全(wss)“需要升级错误 426”?

  • 772

我试图在我的 Nginx 服务器上配置一个 Websocket 代理,但不幸的是,我没有让它工作。我在这里阅读了各种帖子,但我无法让服务器正常工作。我认为这与客户端与服务器的连接有关。本地 om 我的电脑一切正常

客户端代码:

 var port = new osc.WebSocketPort({
          url: "wss://circusfamilyprojects.nl/"
        });

服务器代码:

var wss = new WebSocket.Server({
    port: 8083
});

这是我在 Ngnix 上的配置:

# custom code for hop by hop headers
    map $http_upgrade $connection_upgrade {
        default upgrade;
        ''      close;
    }


    #custom code for connection with websocket this is the port on the server
     upstream websocket  {
        server 178.62.209.37:8083;
    }

server {

      listen [::]:443 ssl ipv6only=on; # managed by Certbot
      listen 443 ssl; # managed by Certbot
      ssl_certificate /etc/letsencrypt/live/circusfamilyprojects.nl/fullchain.pem; # managed by Cert$
      ssl_certificate_key /etc/letsencrypt/live/circusfamilyprojects.nl/privkey.pem; # managed by Ce$
      include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
      ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

       root /var/www/html/vue/cfdomotica/server/public;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

       server_name  circusfamilyprojects.nl www.circusfmailyprojects.nl; # managed by Certbot

      location / {
            proxy_pass http://websocket;
            proxy_set_header HOST $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass_request_headers on;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;

        }
}

server {
    if ($host = www.circusfamilyprojects.nl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = circusfamilyprojects.nl) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 8080 ;
        listen [::]:8080 ;
    server_name  circusfamilyprojects.nl;
    return 404; # managed by Certbot
}

在我的浏览器中,我收到消息“状态代码:需要 426 升级”希望有人能帮助我,在此先感谢!

ssl nginx certbot websocket
  • 1 1 个回答
  • 1997 Views

1 个回答

  • Voted
  1. Best Answer
    Dominique
    2020-05-06T02:25:31+08:002020-05-06T02:25:31+08:00

    我自己解决了这个问题,将端口 443 的服务器块和 WebSocket 客户端的服务器块分开。我在端口 8086 上为客户端做了服务器块。

    • 0

相关问题

  • 如何使用 Tomcat 5.5 更新 SSL 证书

  • 为 IIS6 自行生成 SSL 证书?

  • plesk 上的域和子域 ssl 访问

  • 如何设置 SSL 邮件服务器?

  • 如何通过 SVN 命令行接受 SSL 证书?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve