宝塔双11特惠活动,企业版2299元/3年,SSL证书低至9.9元!查看活动
当前位置:论坛首页 > Linux面板 > 建议

【已解答】更新Linux面板11.2.0后,出现Internal Server Error

发表在 Linux面板昨天 10:50 [复制链接] 1 42

先说下我的环境是win11,使用wsl2 安装了 Ubuntu 22.04.1 LTS, 今天更新了宝塔11.2.0后出现了Internal Server Error,更新和修复面板都没用, 查了一下错误日志,发现是AttributeError: 'NoneType' object has no attribute 'split'
  1. During handling of the above exception, another exception occurred:

  2. Traceback (most recent call last):

  3. File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 2529, in wsgi_app

  4. response = self.full_dispatch_request()

  5. File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1825, in full_dispatch_request

  6. rv = self.handle_user_exception(e)

  7. File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1669, in handle_user_exception

  8. return self.handle_http_exception(e)

  9. File "/www/server/panel/pyenv/lib/python3.7/site-packages/flask/app.py", line 1609, in handle_http_exception

  10. return self.ensure_sync(handler)(e)

  11. File "/www/server/panel/BTPanel/__init__.py", line 381, in error_404

  12. return public.error_not_login()

  13. File "class/public.py", line 5755, in error_not_login

  14. client_status = check_client_info()

  15. File "class/public.py", line 8272, in check_client_info

  16. remote_addr = get_client_ip()

  17. File "class/public.py", line 834, in get_client_ip

  18. return GetClientIp()

  19. File "class/public.py", line 807, in GetClientIp

  20. forwarded_ips = request.headers.get('X-Forwarded-For').split(',')

  21. AttributeError: 'NoneType' object has no attribute 'split'
复制代码


临时解决方案:
先备份,然后找到\www\server\panel\class\public.py 的 GetClientIp 方法
直接覆盖

def GetClientIp():
    from flask import request
    ipaddr = request.remote_addr
    if ipaddr:
        ipaddr = ipaddr.replace('::ffff:', '')
    if ipaddr in ('127.0.0.1', '::1', "localhost"): # 仅信任本地代理,在本地代理时,认为是开启了免端口访问
        x_forwarded_for = request.headers.get('X-Forwarded-For')
        if x_forwarded_for:  # 添加检查,确保 X-Forwarded-For 不为 None
            forwarded_ips = x_forwarded_for.split(',')
            if len(forwarded_ips) > 0:
                ipaddr = forwarded_ips[-1]
        elif "X-Real-Ip" in request.headers:
            ipaddr = request.headers.get('X-Real-Ip')

    if not isinstance(ipaddr, str):
        return '未知IP地址'

    ipaddr = ipaddr.replace('::ffff:', '')

    if not check_ip(ipaddr): return '未知IP地址'
    return ipaddr




使用道具 举报 只看该作者 回复
发表于 昨天 14:11 | 显示全部楼层
命令行bt 16 修复至最新版即可
使用道具 举报 回复 支持 反对
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

普通问题处理

论坛响应时间:72小时

问题处理方式:排队(仅解答)

工作时间:白班:9:00 - 18:00

紧急运维服务

响应时间:3分钟

问题处理方式:宝塔专家1对1服务

工作时间:工作日:9:00 - 18:30

宝塔专业团队为您解决服务器疑难问题

点击联系技术免费分析

工作时间:09:00至18:30

快速回复 返回顶部 返回列表