Wp-cli: Undefined index HTTP_X_FORWARDED

Created on 13 Mar 2016  路  3Comments  路  Source: wp-cli/wp-cli

I require the lines in wp-config.php for SSL termination, wp cli complains about them

if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
        $_SERVER['HTTPS']='on';

This is the error thrown by wp cli when I run it in the root of the WP installation

Undefined index: HTTP_X_FORWARDED_PROTO in phar:///usr/bin/wp/php/WP_CLI/Runner.php(756) : eval()'d code on line 57

I still seem to be able to install plugins but that's all I've tried so far

unconfirmed

Most helpful comment

I require the lines in wp-config.php for SSL termination, wp cli complains about them

$_SERVER isn't populated in the CLI context. You'll need to check if the index is set:

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
        $_SERVER['HTTPS']='on';

All 3 comments

I require the lines in wp-config.php for SSL termination, wp cli complains about them

$_SERVER isn't populated in the CLI context. You'll need to check if the index is set:

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
        $_SERVER['HTTPS']='on';

why after almost 4 years it still an issue without any proper solution ?
why we still need to tweak wp-config.php and it didn't became a standard parameter into it ?

and even with the solution mentioned by @danielbachhuber it still not working for me
...

I'm using this snippet @JDmnT , did you do the define as well?

https://gist.github.com/wgroenewold/68fcaaabfbf939282b1a5cddd6f636e8

Was this page helpful?
0 / 5 - 0 ratings