nginx - Nginx $http_upgrade 始终为空
问题描述
我有一个 websocket 程序,我使用 nginx 作为路由器。问题是 websocket 需要 Upgrade 标头才能正常工作。我确定我的 nginx 配置是正确的,并且我的程序运行正常。(我用本地主机测试)。细节和证据?我把它留在下面。我希望找到解决方案
相关配置;
proxy_set_header Upgrade $http_x_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header UpgradeTest $http_upgrade+"_test"; #for be sure
proxy_set_header UpgradeXTest $http_x_upgrade+"_test"; #for be sure
proxy_set_header Connection "Upgrade"; #this is ok
要求;
curl -v 'https://mywebsocketserver.example/abc' -H 'Upgrade: websocket' -H 'Connection: Upgrade' -H "TestHeader: IAmHere"
响应(标题)(go-map);
map[
Testheader: IAmHere
Accept: */*
Accept-Encoding: gzip
Cdn-Loop: cloudflare
Cf-Connecting-Ip: <myip>
Cf-Ray: 65a1b1ff3a30fd66-ATH
Cf-Request-Id: 0a78ef738d0000fd66e76a8000000
Cf-Visitor: {"scheme":"https"}
Connection: Upgrade
Demote-Host: <myip>
Upgradetest: +"_test"
Upgradextest: +"_test"
User-Agent: curl/7.76.0
X-Forwarded-Proto: https
X-Real-Ip: <myip>
]
那么,我的 Upgrade [$http_upgrade] 标头在哪里 :)
解决方案
推荐阅读
- javascript - 在 React 中使用 Canvas 渲染视频
- java - 是否可以使用 Flutter 制作实现 Accessibility API 的 Android 应用?
- python-3.x - Python OOP 和递归:什么时候放“self”,什么时候不放
- javascript - 如何编写一个函数来检查井字游戏 js 中的获胜者?
- regex - QRegExp 用法:如何从 html 字符串中获取图像名称?
- c++ - 在扩展已知类的未知类中调用函数
- php - ACF 功能不显示
- php - 来自控制器 Codeigniter 的复选框未显示在数据表 ajax 调用中
- c++ - C++ 数组指针如何具有不同的位置,但指向同一个元素?
- windows - git show HEAD~1:.gitignore 命令导致 Windows 64 位中出现奇怪的字符