Fix login cyberpanel on proxy cloudflare

 


For Resolving IP Session Reuse Error in CyberPanel on Proxy Cloudflare


Step 1: Access the Server via SSH

- Log into your server via SSH with root privileges.


Step 2: Backup and Edit the IP Check File

- Create a backup of the file to avoid data loss:

"cp /usr/local/CyberCP/CyberCP/secMiddleware.py /usr/local/CyberCP/CyberCP/secMiddleware.py.bak"

- Open the secMiddleware.py file with nano for editing:

"nano /usr/local/CyberCP/CyberCP/secMiddleware.py"

- Replace all occurrences of (request) with 'True-Client-IP' in the IP check code by using the code below exactly as presented:

"try:

    uID = request.session['userID']

    admin = Administrator.objects.get(pk=uID)

    ipAddr = request.META.get('True-Client-IP')  # Use 'True-Client-IP' for Cloudflare


    if ipAddr.find('.') > -1:

        if request.session['ipAddr'] == ipAddr or admin.securityLevel == secMiddleware.LOW:

            pass

        else:

            del request.session['userID']

            del request.session['ipAddr']

            logging.writeToFile(request.META.get('True-Client-IP'))

            final_dic = {'error_message': "Session reuse detected, IPAddress logged.",

                         "errorMessage": "Session reuse detected, IPAddress logged."}

            final_json = json.dumps(final_dic)

            return HttpResponse(final_json)

    else:

        ipAddr = request.META.get('True-Client-IP').split(':')[:3]


        if request.session['ipAddr'] == ipAddr or admin.securityLevel == secMiddleware.LOW:

            pass

        else:

            del request.session['userID']

            del request.session['ipAddr']

            logging.writeToFile(request.META.get('True-Client-IP'))

            final_dic = {'error_message': "Session reuse detected, IPAddress logged.",

                         "errorMessage": "Session reuse detected, IPAddress logged."}

            final_json = json.dumps(final_dic)

            return HttpResponse(final_json)

except:

    pass"

- Save and close nano:

   Press Ctrl + O to save.

   Press Enter to confirm.

   Then, press Ctrl + X to exit.


Step 3: Restart CyberPanel Service

To apply the changes, restart the CyberPanel service with this command:

"systemctl restart lscpd"


Step 4: Test the Connection

Please Select Embedded Mode For Blogger Comments

Lebih baru Lebih lama

Bottom Ad [Post Page]