{"id":8420601,"date":"2016-11-10T18:26:28","date_gmt":"2016-11-10T18:26:28","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/apache-fast-cgi-issues\/"},"modified":"2016-11-10T18:26:28","modified_gmt":"2016-11-10T18:26:28","slug":"apache-fast-cgi-issues","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/apache-fast-cgi-issues\/","title":{"rendered":"Apache + fast CGI issues"},"content":{"rendered":"<p>Hi, I am using apache 2.4 plus PHP-FPM setup.<\/p>\n<p>This setup has some issues with basic authentication headers that are cut by Apache and PHP knows nothing about auth attempts. I guess all FastCGI modes are behaving similar.<\/p>\n<p>My solution after some hours of research is:<br \/>\n&#8211; setup this in the .htaccess file, in order to pass the authorization header directly to PHP<\/p>\n<pre><code># BEGIN WordPress\nSetEnvIf Authorization &quot;(.*)&quot; HTTP_AUTHORIZATION=$1\n...<\/code><\/pre>\n<p>Then in your Application_Passwords class I had to edit like this:<\/p>\n<pre><code>\tpublic static function rest_api_auth_handler( $input_user ){\n\t\t\/\/ Don&#039;t authenticate twice\n\t\tif ( ! empty( $input_user ) ) {\n\t\t\treturn $input_user;\n\t\t}\n\n\t\tif(preg_match(&#039;\/Basic+(.*)$\/i&#039;, $_SERVER[&#039;REDIRECT_HTTP_AUTHORIZATION&#039;], $matches))\n\t\t{\n\t\t\tlist($_SERVER[&#039;PHP_AUTH_USER&#039;], $_SERVER[&#039;PHP_AUTH_PW&#039;]) = explode(&#039;:&#039; , base64_decode(substr($_SERVER[&#039;REDIRECT_HTTP_AUTHORIZATION&#039;], 6)));\n\t\t}\n\t\t\n\t\t\/\/ Check that we&#039;re trying to authenticate\n\t\tif ( ! isset( $_SERVER[&#039;PHP_AUTH_USER&#039;] ) ) {\n\t\t\treturn $input_user;\n\t\t}\n...<\/code><\/pre>\n","protected":false},"template":"","class_list":["post-8420601","topic","type-topic","status-publish","hentry","topic-tag-cgi","topic-tag-php-fpm"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8420601","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/8420601\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=8420601"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}