Reverse Proxy Configuration
-
Hi,
does the plugin respect a wordpress reverse proxy configuration? We are not able to authenticate with our algolia credentials. On pages without reverse proxy the installation is working properly.
Can you name the endpoints that are requested during activation, like e.g. “auth.algolia.com”?
Thanks and have a nice day,
Jan
-
Hi @jwinterfeld
We’re making use of https://github.com/algolia/algoliasearch-client-php to handle all of the API client requests, specifically the 3.3.x release range https://github.com/algolia/algoliasearch-client-php/tree/3.3.0
Not sure how much you’d be able to get out of that for possible API endpoints. Algolia support themselves may be able to provide some information as well, to help with the reverse proxy details.
Hi Michael,
thank you!
Currently we are experiencing issues while authenticating against algolia using “WP Search with Algolia”. I think this is plugin related. Are you respecting proxy configurations from the wordpress config? (we double checked the credentials)
Perhaps this is the recommendation from Algolia: https://support.algolia.com/hc/en-us/articles/17789246970641-How-do-I-use-Python-API-client-with-proxy
Thanks and have a nice day,
Jan
Until I’m told otherwise, I have to assume so, or at least we’re not intentionally ignoring/disregarding them. Closest I can think of for potentially integrating with reverse proxying would be the code in https://github.com/WebDevStudios/wp-search-with-algolia/tree/main/includes/factories where we’re doing some of the initial wiring up.
Admittedly I’m not that well versed with regards to reverse proxy thing and in response to that, how/where one could potentially change connection attempts within the plugin’s code here.
This is also why I pointed to the package from Algolia where they’re maintaining a lot of code that we make use of externally, but don’t control internally. The question at that point would be how to best pass in custom values that pass through to that library.
-
This reply was modified 1 year, 7 months ago by
Michael Beckwith.
Thanks Michael.
I did some investigation and believe we should extend the
SearchConfig::createmethod (reference: SearchConfig.php#L15) to accept “hosts” and “headers” as parameters. Does that make sense to you?Related Algolia Docs:
– https://www.algolia.com/doc/libraries/php/v3/customize/#use-a-custom-host
– https://www.algolia.com/doc/libraries/php/v3/customize/#add-http-headers-to-every-requestOverall, yes, but we can’t modify that
SearchConfig.phpfile as that’s part of the composer package for the Algolia Search client.That said, I know we have https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/includes/factories/class-algolia-search-client-factory.php#L60-L86 where we’ve previously customized some details for the search config, and I believe we should be fine with adding in more conditionals. Perhaps we should even fill in all the missing items from https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/vendor_prefixed/algolia/algoliasearch-client-php/src/Config/SearchConfig.php#L25-L39
Worth trying out in adding your values in the the
class-algolia-search-client-factory.phparound line 85 just to help confirm that things take like needed. If yes, then we can get an issue opened and a PR in place to fill in the missing config options.@jwinterfeld Did you ever get something working here, based on feedback?
@tw2113 thanks. We are still working on it. Currently we were able isolate the issue and reproduce it. Hopefully we will be able to provide further information within 2 weeks.
Sounds good. Thanks for the update.
@tw2113 we resolved the issue without code modification. After investigating the code we found the filter
algolia_http_client_optionsin this file: https://github.com/WebDevStudios/wp-search-with-algolia/blob/main/includes/factories/class-algolia-http-client-interface-factory.phpWe resolved it by declaring a function in the theme functions.php file:
if (! function_exists('dur_algolia_http_client_options')) :
function dur_algolia_http_client_options($options)
{
$options['CURLOPT_PROXY'] = WP_PROXY_HOST . ':' . WP_PROXY_PORT;
return $options;
}
add_filter('algolia_http_client_options', 'dur_algolia_http_client_options', 10, 1);
endif;My recommendation is to update the docs and explain the filter instead of modifying the plugin. What do you think?
Added https://github.com/WebDevStudios/wp-search-with-algolia/wiki/Proxy quick, at least based on your code above.
May still handle my filters idea from https://ww.wp.xz.cn/support/topic/reverse-proxy-configuration/#post-18149029 but that’s not needed today by any means.
Thanks for the followup @jwinterfeld
-
This reply was modified 1 year, 7 months ago by
The topic ‘Reverse Proxy Configuration’ is closed to new replies.