更换Cloudflare域名服务器后phpMyAdmin登录页空白问题求助
Hey there, I’ve run into similar headaches when pairing Cloudflare with phpMyAdmin—let’s get this sorted out for you!
What’s Causing the Problem?
That error message spells it out clearly: Cloudflare’s Rocket Loader script (rocket-loader.min.js from ajax.cloudflare.com) is getting blocked by phpMyAdmin’s default Content Security Policy (CSP). phpMyAdmin’s default CSP only allows scripts from its own domain, inline scripts, and eval functions, but it doesn’t whitelist Cloudflare’s CDN domain.
Solution 1: Disable Cloudflare’s Rocket Loader (Quickest Fix)
If you don’t depend on Rocket Loader for performance gains, this is the fastest way to fix the issue:
- Log into your Cloudflare dashboard and select your website’s domain
- Head to the Speed tab, then navigate to the Optimization section
- Find the Rocket Loader option and toggle it to Off
- Wait 2-3 minutes for Cloudflare’s cache to update, then refresh your phpMyAdmin login page. It should load normally now.
Solution 2: Update phpMyAdmin’s CSP to Allow Cloudflare Scripts
If you want to keep Rocket Loader enabled, you’ll need to adjust phpMyAdmin’s CSP rules to whitelist Cloudflare’s domain:
- Locate phpMyAdmin’s main configuration file:
config.inc.php(this is usually in your phpMyAdmin installation directory, likeC:\Apache24\htdocs\phpmyadminon Windows Server) - Open the file with a text editor and add or modify the following line:
$cfg['ContentSecurityPolicy'] = "script-src 'self' 'unsafe-inline' 'unsafe-eval' ajax.cloudflare.com;";
- Save the file and restart your Apache web server on Windows Server (you can do this via the Services console or run
net stop Apache2.4 && net start Apache2.4in Command Prompt) - Refresh phpMyAdmin—you should now see the login page without issues.
Extra Troubleshooting Tips
- If updating
config.inc.phpdoesn’t work, check your Apache configuration (like.htaccessfiles or virtual host settings) to make sure there isn’t another CSP rule overriding phpMyAdmin’s setting. Any additional CSP rules must also includeajax.cloudflare.comin thescript-srcdirective. - You can also try temporarily disabling Cloudflare’s Auto Minify (under Speed > Optimization) to rule out conflicts with minified scripts.
内容的提问来源于stack exchange,提问作者Ray Yen

