简体   繁体   English

阿尔及利亚搜索索引失败

[英]Algolia search index fail

I have installed Algolia search plugin 1.7.0 in my WordPress site. 我已经在我的WordPress网站上安装了Algolia搜索插件1.7.0。 I have also set it up and when I go into indexing the following shows up: 我也进行了设置,当我建立索引时,将显示以下内容:

wp_remote_post() failed, indexing won't work. Checkout the logs for more details.
URL called: http://45.77.12.19/wp-admin/admin-post.php
Array
(
    [headers] => Requests_Utility_CaseInsensitiveDictionary Object
        (
            [data:protected] => Array
                (
                    [server] => nginx/1.12.0
                    [date] => Tue, 25 Apr 2017 02:23:09 GMT
                    [content-type] => text/html
                    [content-length] => 195
                    [www-authenticate] => Basic realm="Restricted"
                )
        )

401 Authorization Required

I have tried to add define( 'ALGOLIA_LOOPBACK_HTTP', true ) in the wp-config.php file and followed other steps explained: 我尝试在wp-config.php文件中添加define('ALGOLIA_LOOPBACK_HTTP',true),然后按照说明的其他步骤进行操作:
https://community.algolia.com/wordpress/frequently-asked-questions.html https://community.algolia.com/wordpress/frequently-asked-questions.html

I am at a dead end and unsure of what to do now as the algolia indexing won't happen. 我处于死胡同,不确定由于阿尔戈利亚索引编制将不会发生,现在该怎么办。 How can I resolve this? 我该如何解决?

The Algolia plugin for WordPress needs to be able to access the admin interface over HTTP or HTTPS. 用于WordPress的Algolia插件需要能够通过HTTP或HTTPS访问管理界面。 This is the way it creates a loop to deal with the pending tasks. 这是它创建处理未决任务的循环的方式。

According to your logs: 'Basic realm="Restricted"', your admin seems protected behind Basic Auth (htpasswd). 根据您的日志:'Basic realm =“ Restricted”',您的管理员似乎受到基本身份验证(htpasswd)的保护。

To make the queue work in your case, you should provide the plugin with the credentials. 为了使队列适合您的情况,您应该为插件提供凭据。

Here is what you need to add to the functions.php file of your active theme. 这是您需要添加到活动主题的functions.php文件中的内容。

<?php
// In your current active theme functions.php.
define( 'MY_USERNAME', 'test' );
define( 'MY_PASSWORD', 'test' );

function custom_loopback_request_args( array $request_args ) {
    $request_args['headers']['Authorization'] = 'Basic ' . base64_encode( MY_USERNAME . ':' . MY_PASSWORD );

    return $request_args;
}

add_filter( 'algolia_loopback_request_args', 'custom_loopback_request_args' );

Note that this will probably change in the upcoming weeks as we are working towards removing that logic. 请注意,随着我们努力删除该逻辑,这可能会在接下来的几周内改变。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM