分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 前端开发

关于 Nginx 配置 WebSocket 400 问题

发布时间:2023-09-06 01:57责任编辑:董明明关键词:Web配置

今天把项目升级了 asp.net core 到 2.1 的版本,使用了 signalr  的功能,由于阿里云不支持 websocket 协议,所以使用了 nginx 代理方式来解决,后续就报了一个登陆的 404 错误。

POST http://xxx.xxx.xxx.xxx/account/login HTTP/1.1Host: xxx.xxx.xxx.xxxConnection: keep-aliveContent-Length: 217Cache-Control: max-age=0Origin: http://xxx.xx.xxx.xxUpgrade-Insecure-Requests: 1Content-Type: application/x-www-form-urlencodedUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8Referer: http://xxx.xx.xxx.xx/account/loginAccept-Encoding: gzip, deflateAccept-Language: zh-CN,zh;q=0.9Cookie: .AspNetCore.Antiforgery.7cgpZYq1ZXs=CfDJ8KJwTda_rr5JqCpgr4JkvXPer9JtjzFiA6KXhxp_8m9gZOJgqfDqP-AhE7u-AgDz3PCB1Ij7YCwQKP6qevtpPPMZcWfGlk4-6v_v6TqFe8yPcQ-_wPmB5OqgxSpALzp9mP13S7HQVhSg6T8Hxm7Q1tI__RequestVerificationToken=CfDJ8KJwTda_rr5JqCpgr4JkvXOlA8q_Wj9j8_hKa5BXlVTLeL65qofkijsny-O8pTxOIc7j5Vqrkw9SrKV-xOoChhghUf60qv9Juqm_epLjs-qKXOkG5SEhETtnrWDmLM8nlhEpMkOyuY2p5GnGNtZ7m4k&userName=irving&pwd=xxxHTTP/1.1 400 Bad RequestServer: nginx/1.10.3 (Ubuntu)Date: Fri, 01 Jun 2018 14:52:04 GMTContent-Length: 0Connection: keep-alive
 ??server { ????????listen 80; ????????location / { ???????????proxy_pass http://localhost:5000; ???????????proxy_set_header X-Real-IP $remote_addr; ???????????proxy_set_header Host $host; ???????????proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; ????????} ??????location ~ ^/(.*)/ws${ ???????proxy_pass http://localhost:5000; ???????????proxy_set_header Upgrade $http_upgrade; ???????????proxy_set_header Connection "Upgrade"; ???????????proxy_set_header Host $http_host; ???????????proxy_read_timeout 36000s; ???????} ??????}

https://www.orgleaf.com/2280.html

http://nginx.org/en/docs/http/websocket.html

http://dbaplus.cn/news-21-1129-1.html

https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04

关于 Nginx 配置 WebSocket 400 问题

原文地址:https://www.cnblogs.com/Irving/p/9124221.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved