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

POST http://xxx.xxx.xxx.xxx/account/login HTTP/1.1
Host: xxx.xxx.xxx.xxx
Connection: keep-alive
Content-Length: 217
Cache-Control: max-age=0
Origin: http://xxx.xx.xxx.xx
Upgrade-Insecure-Requests: 1
Content-Type: application/x-www-form-urlencoded
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Referer: http://xxx.xx.xxx.xx/account/login
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: .AspNetCore.Antiforgery.7cgpZYq1ZXs=CfDJ8KJwTda_rr5JqCpgr4JkvXPer9JtjzFiA6KXhxp_8m9gZOJgqfDqP-AhE7u-AgDz3PCB1Ij7YCwQKP6qevtpPPMZcWfGlk4-6v_v6TqFe8yPcQ-_wPmB5OqgxSpALzp9mP13S7HQVhSg6T8Hxm7Q1tI __RequestVerificationToken=CfDJ8KJwTda_rr5JqCpgr4JkvXOlA8q_Wj9j8_hKa5BXlVTLeL65qofkijsny-O8pTxOIc7j5Vqrkw9SrKV-xOoChhghUf60qv9Juqm_epLjs-qKXOkG5SEhETtnrWDmLM8nlhEpMkOyuY2p5GnGNtZ7m4k&userName=irving&pwd=xxx HTTP/1.1 400 Bad Request
Server: nginx/1.10.3 (Ubuntu)
Date: Fri, 01 Jun 2018 14:52:04 GMT
Content-Length: 0
Connection: 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 问题的更多相关文章

  1. nginx配置websocket

    有时候我们需要给websocket服务端做一下nginx的配置,比如需要给websocket服务端做负载均衡,或者,有些系统要求访问websocket的时候不能带端口,这时候我们就需要用nginx来进 ...

  2. Nginx 配置Websocket

    Nginx反向代理配置websocket nginx.org 官网推荐如下的配置,也可以直接看官网:http://nginx.org/en/docs/http/websocket.html http ...

  3. Nginx配置websocket的安全协议wss

    //nginx配置wss访问方式 map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream webso ...

  4. Nginx配置WebSocket反向代理(Tomcat+Nginx)

    @toc WebSocket 和HTTP协议不同,但是WebSocket中的握手和HTTP中的握手兼容,它使用HTTP中的Upgrade协议头将连接从HTTP升级到WebSocket.这使得WebSo ...

  5. centos下使用nginx 配置websocket,https升级wss协议

    服务端代码/***/ // 服务端代码 var express = require('express'); var app = express(); var path = require('path' ...

  6. 从配置websocket理解nginx

    原文地址:http://www.niu12.com/article/2 今天由于写了一个简单的基于h5 websoceket的聊天室,再本地都是好好了.     但是上到服务器后就发现无法行的通, 查 ...

  7. 【Nginx】面试官问我Nginx能不能配置WebSocket?我给他现场演示了一番!!

    写在前面 当今互联网领域,不管是APP还是H5,不管是微信端还是小程序,只要是一款像样点的产品,为了增加用户的交互感和用户粘度,多多少少都会涉及到聊天功能.而对于Web端与H5来说,实现聊天最简单的就 ...

  8. 在vue中如何使用WebSocket 以及nginx代理如何配置WebSocket

    WebSocket WebSocket是一种网络传输协议,可在单个TCP连接上进行全双工通信.浏览器和服务器只需要完成一次握手,两者之间就可以创建持久性的连接,并进行双向数据传输. 浏览器支持情况 现 ...

  9. nginx 支持websocket

    nginx 反向代理websocket nginx配置 请求地址及路径:ws://x.x.x.x/web/springws/websocket.ws 解析 map 指令 上面 nginx.conf 配 ...

随机推荐

  1. 365. Water and Jug Problem量杯灌水问题

    [抄题]: 简而言之:只能对 杯子中全部的水/容量-杯子中全部的水进行操作 You are given two jugs with capacities x and y litres. There i ...

  2. [leetcode]43. Multiply Strings高精度乘法

    Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and ...

  3. java 线程Thread 技术--volatile关键字

    java 语言中允许线程访问共享变量,为了保证共享变量能被准确和一致的更新,Java 语言提供了volatile 关键字,也就是我们所说的内存一致性: 问题抛出:(尝试去运行下面代码,以及将volat ...

  4. Jmeter创建一个web测试计划

    1.  下载Jmeter 下载地址:http://jmeter.apache.org/download_jmeter.cgi 下载后解压到你想“安装”的路径下,比如: D:\Program Files ...

  5. [原]CentOS 7.2 1511部署L2TP/IPsec服务器及客户端

    快过年了,感觉从去年开始,我们公司就变成了“别人的公司”,基本上提前一星期就放假了,好开心.正好可以利用这一段时间,把前段时间一些疑惑的问题解决下:) 然而挡在面前的一个拦路虎是:很多时候不能愉快的G ...

  6. js原生的节点操作API

    // yi获取元素节点 //一 :过id的方式( 通过id查找元素,大小写敏感,如果有多个id只找到第一个) document.getElementById('div1'); // 通过类名查找元素, ...

  7. Spring Boot学习笔记:整合Shiro

    Spring Boot如何和Shiro进行整合: 先自定义一个Realm继承AuthorizingRealm,并实现其中的两个方法,分别对应认证doGetAuthenticationInfo和授权do ...

  8. javascript Date对象扩展相关function

    本篇均以es5为主: 1,月份加减来推日期 // 根据所给月份往后推出日期 function getMonth(count) { var date = new Date(); var year = d ...

  9. ABP框架系列之四十五:(Quartz-Integration-Quartz-集成)

    Introduction Quartz is a is a full-featured, open source job scheduling system that can be used from ...

  10. kei下无法跳转到函数的定义处

    1 勾选“option for target”----“output”----"Browse information" 2 重新编译整个工程, 执行上面两个步骤就可以跳转了.