lede
lede copied to clipboard
使用nginx时,Turbo ACC插件获取状态502
反馈bug/问题模板,提建议请删除
1.关于你要提交的问题
Q:是否搜索了issue (使用 "x" 选择)
- [x] 没有类似的issue
2. 详细叙述
(1) 具体问题
A:使用luci-nginx-ssl,Turbo ACC插件在开启第一个选项时,状态获取显示502,关闭第一个选项时恢复;同时其余插件获取状态正常
(2) 路由器型号和固件版本
A:x86_64 OpenWrt R22.9.1 / LuCI Master (git-22.270.62759-d376b9d)
(3) 详细日志
A:
nginx日志
192.168.1.x - - [03/Oct/2022:19:21:16 +0800] "GET /cgi-bin/luci/admin/network/turboacc/status?_=0.1644270072060614 HTTP/1.1" 502 559 "http://192.168.1.1:8080/cgi-bin/luci/admin/network/turboacc" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36 Edg/105.0.1343.53"
nginx配置
server {
listen 192.168.1.1:8080;
server_name localhost;
index nginx.html index.html index.htm index.php default.html default.htm default.php;
root /www;
client_max_body_size 300M;
location /cgi-bin/luci {
index index.html;
include uwsgi_params;
uwsgi_param SERVER_ADDR $server_addr;
uwsgi_modifier1 9;
uwsgi_pass unix:////var/run/luci-webui.socket;
}
location ~ /cgi-bin/cgi-(backup|download|upload|exec) {
include uwsgi_params;
uwsgi_param SERVER_ADDR $server_addr;
uwsgi_modifier1 9;
uwsgi_pass unix:////var/run/luci-cgi_io.socket;
}
location /luci-static {
error_log stderr crit;
}
location /ubus {
ubus_interpreter;
ubus_socket_path /var/run/ubus/ubus.sock;
ubus_parallel_req 2;
}
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 30d;
}
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 30d;
}
}
遇到同样的问题,搜寻答案,发现楼主提出来了。敬礼,敬礼
我这边是用 nginx 反代出现:net::ERR_HTTP2_PROTOCOL_ERROR
谷歌了一下,貌似是 HTTP2 需要标准的 header 头
你这个是配置了http2才会出现的,报错不是502,一般是https配的有问题; 我这个是502,是网关报错
你这个是配置了http2才会出现的,报错不是502,一般是https配的有问题; 我这个是502,是网关报错
我这个问题和它这个一模一样:https://www.jianshu.com/p/8d8de360f8ff 谷歌上的哪些什么改缓存的方法都试过了,其他页面也都正常
@tanst 可以去了解下http2,http2传输是二进制压缩数据(wiki),如果数据不对,浏览器获取到数据后会解析失败报错,你的问题最简单的解决办法应该是关掉http2
尝试将lua代码中检查fastpath的代码输出定向到/dev/null后恢复正常
local function fastpath_status()
return luci.sys.call("/etc/init.d/turboacc check_status fastpath >/dev/null") == 0
end
尝试将lua代码中检查fastpath的代码输出定向到/dev/null后恢复正常
local function fastpath_status() return luci.sys.call("/etc/init.d/turboacc check_status fastpath >/dev/null") == 0 end
改哪个文件?
@tanst /usr/lib/lua/luci/controller/turboacc.lua
我的使用最新的代码也出一样的问题
尝试将lua代码中检查fastpath的代码输出定向到/dev/null后恢复正常
local function fastpath_status() return luci.sys.call("/etc/init.d/turboacc check_status fastpath >/dev/null") == 0 end
改了需要重启吗?
尝试将lua代码中检查fastpath的代码输出定向到/dev/null后恢复正常
local function fastpath_status() return luci.sys.call("/etc/init.d/turboacc check_status fastpath >/dev/null") == 0 end
试了试,无效
尝试将lua代码中检查fastpath的代码输出定向到/dev/null后恢复正常
local function fastpath_status() return luci.sys.call("/etc/init.d/turboacc check_status fastpath >/dev/null") == 0 end
试了,可以。多谢!
改完后: rm /tmp/luci-indexcache rm -rf /tmp/luci-modulecache/
将 nginx 错误日志调整为 info 级别发现:
upstream sent invalid header: "Flow\\x20..." while reading response header from upstream
发现是无法处理/etc/init.d/turboacc check_status fastpath
命令的输出: Flow Offloading
中的空格
导致 response 中的 header 出现:Flow OffloadingStatus: 200 OK
,而 HTTP Header 中不允许出现空格,所以 nginx 会出现 502 错误。
同理,MediaTek HWNAT
和Shortcut-FE ECM
也会有此问题
不知道哪里把/etc/init.d/turboacc check_status fastpath
的结果给加到 Header 里去了
修改后测试成功,总结如下
我的错误信息是 [error] 4188#0: *64 upstream sent invalid header: "Flow\x20..." while reading response header from upstream, client: 192.168.1.228, server: _lan, request: "GET /cgi-bin/luci/admin/network/turboacc/status?1698850818711 HTTP/1.1", upstream: "uwsgi://unix:////var/run/luci-webui.socket:", host: "192.168.1.1", referrer: "https://192.168.1.1/cgi-bin/luci/admin/network/turboacc"
找到 /usr/lib/lua/luci/controller/turboacc.lua
文件,把对应内容改成
local function fastpath_status()
return luci.sys.call("/etc/init.d/turboacc check_status fastpath >/dev/null") == 0
end
然后运行
rm -rf /tmp/luci-modulecache/
再去配置turboacc,万事大吉