1Panel
1Panel copied to clipboard
[BUG] 获取真实 ip 时 网站的当前状态查询 api 接口出现问题
联系方式
No response
1Panel 版本
1.9.6
问题描述
使用 frp 获取真实 ip 需要修改 nginx 配置,然后点击 当前状态 就会出现 接口 报错,抱歉不知道什么原因不能上传截图
报错接口:
/api/v1/openresty/status
接口报错内容:
{
"code": 500,
"message": "服务内部错误: Get \"http://127.0.0.1/nginx_status\": EOF",
"data": null
}
重现步骤
第一步: 修改 nginx 配置 http 节点下增加 如下内容
http {
# ...其他配置
real_ip_header proxy_protocol;
real_ip_recursive on;
set_real_ip_from 127.0.0.0/24;
set_real_ip_from 192.168.1.0/24;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
}
第二步: 修改随意网站的 server 节点 ,修改如下,增加 proxy_protocol
server {
# ...其他配置
listen 443 ssl http2 proxy_protocol;
listen [::]:443 ssl http2 proxy_protocol;
}
第三步
点击 1panel 菜单中的 网站 - 点击 设置 - 点击 当前状态 就会出现报错提示
如果需要 frp 的配置
frp 的证书就自己生成吧...
frpc.toml 配置
transport.tls.certFile = "/to/cert/path/client.crt" transport.tls.keyFile = "/to/key/path/client.key" transport.tls.trustedCaFile = "/to/ca/path/ca.crt"
frps.toml 配置
transport.tls.certFile = "/to/cert/path/server.crt" transport.tls.keyFile = "/to/key/path/server.key" transport.tls.trustedCaFile = "/to/ca/path/ca.crt"
期待的正确结果
No response
相关日志输出
No response
附加信息
这个问题我们暂时没有好的处理办法 大概是 frp 把所有 127.0.0.1 的流量都接管了 所以 1Panel 获取不到 openresty 的接口状态
好吧
尝试了重新在云服务上加入了如下配置,排除了 frp 的使用,依然会出现接口报错的情况
http {
# ...其他配置
real_ip_header proxy_protocol;
real_ip_recursive on;
set_real_ip_from 127.0.0.0/24;
set_real_ip_from 192.168.1.0/24;
set_real_ip_from 10.0.0.0/8;
set_real_ip_from 172.16.0.0/12;
# set_real_ip_from 也尝试过修改为 127.0.0.1 和 在云服务器中的内网 ip 等
}
server {
# ...其他配置
listen 443 ssl http2 proxy_protocol;
listen [::]:443 ssl http2 proxy_protocol;
}
尝试了重新在云服务上加入了如下配置,排除了 frp 的使用,依然会出现接口报错的情况
http { # ...其他配置 real_ip_header proxy_protocol; real_ip_recursive on; set_real_ip_from 127.0.0.0/24; set_real_ip_from 192.168.1.0/24; set_real_ip_from 10.0.0.0/8; set_real_ip_from 172.16.0.0/12; # set_real_ip_from 也尝试过修改为 127.0.0.1 和 在云服务器中的内网 ip 等 }server { # ...其他配置 listen 443 ssl http2 proxy_protocol; listen [::]:443 ssl http2 proxy_protocol; }
我们测试一下