Google reCaptcha not showing in phpbb 3 after moving from HTTP to HTTPS
If you've recently moved phpbb from http to HTTPS and your recaptcha image is not shown on registration page, you might need some extra work.
PHPBB recaptcha module is checking if the protocol is HTTP or HTTPS in
includes/captcha/plugins/phpbb_recaptcha_plugin.php:
Code:
class phpbb_recaptcha extends phpbb_default_captcha
{
var $recaptcha_server = 'http://www.google.com/recaptcha/api';
var $recaptcha_server_secure = 'https://www.google.com/recaptcha/api'; // class constants :(
// We are opening a socket to port 80 of this host and send
// the POST request asking for verification to the path specified here.
var $recaptcha_verify_server = 'www.google.com';
var $recaptcha_verify_path = '/recaptcha/api/verify';
var $challenge;
var $response;
// PHP4 Constructor
function phpbb_recaptcha()
{
$this->recaptcha_server = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? $this->recaptcha_server_secure : $this->recaptcha_server;
}
function init($type)
If the webserver is ngin, the
fastcgi_params.txt file does not instruct nginx to send "HTTPS" variable set to "on" to php. Change it accordingly:
Code:
grep HTTPS /etc/nginx/conf.d/fastcgi_params.txt
fastcgi_param HTTPS on;
Without this, the recaptcha plugin will instruct the browser to load insecure content on a secure webpage (
http://www.google.com/recaptcha/api/challenge?k=<recaptcha-key>) and browser will fail to load the recaptcha image.