تعذر الاتصال بين Discourse و WordPress

I’m facing an issue while connecting Discourse to WordPress using the Discourse Plugin. I’m running Discourse on a Digital Ocean droplet. The setup was performed exactly as mentioned here (discourse/docs/INSTALL-cloud.md at main · discourse/discourse · GitHub). The droplet itself sits behind CloudFlare and HTTPS was setup using Let’s Encrypt (using Set up HTTPS support with Let's Encrypt). The WordPress site is deployed on SiteGround, also behind CloudFlare.

When I add the forum’s root address, API key and administrator username in the plugin settings, in WordPress’ console, it still keeps saying “You’re not connected to Discourse”. Upon further investigating I’ve found that this particular request /site.json%20?api_key=[FILTERED]&api_username=<username> is returning 403 Forbidden even with a fresh, valid API Key and a valid administrator username.

The request to site.json is checking that an API request can be made with the values supplied for the API Key and Publishing Username that are set on WordPress. If you make the request with curl from your local computer, is it working for you? For example, this request with $api_key set to your API key:

curl -X GET 'https://forum.example.com/site.json?api_key=$api_key&api_username=system'

If this is woking for you, you could try installing the WordPress Health Check plugin and looking at the Secure communication row on the Site Status tab to see if it’s finding any issues with communicating with external services using secure connections (SSL.)

This curl command works perfectly fine

curl -X GET "https://community.worldbrain.io/site.json%20\?api_key\=blabla\&api_username\=bla"

Health Check mentions Your WordPress install can communicate securely with other services.

Here is what I’m seeing in HTTP API Calls section

Of course the forum itself is working so it’s pretty bizarre to see Could not resolve host

Can I ask how have you installed SSL on your discourse? Is it a generic cloudflare certificate or something?

Edit:
Indeed it’s cloudflare https://www.whynopadlock.com/results/df748a55-67d9-4477-9502-c618b69cb38c

And I’m assuming you’re running their “Flexible” SSL mode. This explains a lot about why the calls are messed up.

لقد واجهت نفس الخطأ. يرجى المساعدة!

لقد قمت بذلك وحصلت على هذا:

curl -I GET 'https://forum.fususu.com/users/mrsusu.json?api_key=[secretapi]&api_username=mrsusu'

HTTP/1.1 403 Forbidden
Server: CloudFront
Date: Sat, 29 Jun 2019 19:00:27 GMT
Content-Type: text/html
Content-Length: 556
Connection: keep-alive
X-Cache: Error from cloudfront
Via: 1.1 dfb4b390f0fb83a73bab72d387a3e1dc.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: NRT20-C3
X-Amz-Cf-Id: qO_fq0M_GX8wUuqJFCpBDXL6dlJDkKVWJ-BKOSD6qfegOqdNr_837g==

HTTP/1.1 200 OK
Date: Sat, 29 Jun 2019 19:00:28 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Set-Cookie: __cfduid=de8f93857163fcf3bfca002a5af11f38c1561834828; expires=Sun, 28-Jun-20 19:00:28 GMT; path=/; domain=.fususu.com; HttpOnly; Secure
Vary: Accept-Encoding
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Permitted-Cross-Domain-Policies: none
Referrer-Policy: strict-origin-when-cross-origin
X-Discourse-Username: mrsusu
X-Discourse-Route: users/show
Cache-Control: no-cache, no-store
X-Request-Id: 2a4e74b8-3be0-47cf-81e9-fc5682e678c5
Set-Cookie: __profilin=p%3Dt%2Ca%3Dee922625e907ef0b48cfd16cc80c816b%7C20b0d8cc0a038e5816c59c085fca59e5; path=/; secure; HttpOnly

X-Runtime: 0.114832
Strict-Transport-Security: max-age=31536000
Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
Server: cloudflare
CF-RAY: 4eea24bb28432e07-NRT

تم إعداد موقع ووردبريس الخاص بي fususu.com باستخدام - SSL مرن (Cloudflare)،
مع قاعدة صفحة للمنتدى forum.fususu.com - SSL كامل (Cloudflare).

هل تمكنت من تشغيل هذا؟

ليس بعد… استسلمت مؤقتًا ^^!

هل تمكنت من حل هذه المشكلة في أي وقت؟ لدي نفس الإعداد (Discourse على Digital Ocean، وWordPress على Siteground، وكلاهما خلف Cloudflare) ونفس الخطأ. يعمل Curl دون أي مشكلة من جهاز الكمبيوتر المحلي الخاص بي.

هل لديك أي نصيحة؟

كيف تم تكوين شهادة SSL الخاصة بك من جانب Cloudflare؟ هل تستخدم تحسين أداء Cloudflare على Discourse؟

يجب أن تعمل شهادة SSL من Cloudflare في وضع “Full” وليس في وضع “Flexible”.

إذا كان تحسين أداء Cloudflare مفعّلاً على Discourse، فيجب تعطيله عن طريق إنشاء قاعدة صفحة (Page Rule).

إذا لم يساعد ذلك، يرجى مشاركة نطاق Discourse الخاص بك.

عنوان URL هو https://discuss.guidery.com

تم تعطيل الأداء والأمان لنطاق فرعي “discuss” عبر قاعدة صفحة.
تم تعيين SSL إلى “كامل (صارم)”.

رسالة الخطأ التي أراها هي “cURL error 6: Could not resolve host: discuss.guidery.com”، والتي يتم الإبلاغ عنها بواسطة إضافة WP Query Monitor.

تنفيذ نفس أمر cURL من جهاز الكمبيوتر المحلي الخاص بي يعمل دون أي مشكلة.

هل توجد قاعدة جدار حماية تمنع الاتصالات على جانب ووردبريس؟

عندما أتصل عبر SSH بالخادم المشترك (المستضاف بواسطة SiteGround) وأقوم بتشغيل أمر curl يدويًا لطلب تثبيت discourse الخاص بي، أتعامل مع رسالة الخطأ نفسها؛

“curl: (6)” Could not resolve host: discuss.guidery.com".

لقد أنشأت حتى موقع WordPress جديدًا باستخدام نطاق جديد (على الرغم من أنه على نفس خادم Siteground) دون تشغيل DNS عبر Cloudflare، وتلقيت نفس رسالة الخطأ.

هل هناك أي أفكار أخرى؟

ربما يتعين عليك الاتصال بـ SiteGround إذا كانوا يحظرون عنوان IP لخادمك لسبب ما؟

تم الحل. كانت هذه واحدة من تلك الحالات المزعجة التي بدأت “تعمل” فجأة دون أن يُعرف الحل الواضح. سأفترض أنها كانت مشكلة في انتشار DNS، وأن محلّل DNS الخاص بـ Siteground كان بطيئًا لسبب ما.

إذا واجه شخص آخر هذه المشكلة، فإن نصيحتي الوحيدة هي الانتظار 48 ساعة ثم المحاولة مرة أخرى. :-/

تواصل مستخدم آخر يعاني من مشكلة مماثلة مع Siteground. تمكّنوا من حل المشكلة. يحتوي هذا المنشور على تفاصيل حول كيفية إصلاح Siteground للمشكلة: [PAID] Fix cURL error 6 in Discourse WP Plugin - #4 by lucas.bagatini.