# خطأ 502 Gateway على Nginx؟

**URL:** https://meta.discourse.org/t/502-gateway-error-on-nginx/147172
**Category:** Self-hosting
**Created:** [7 أبريل 2020، 7:13م UTC](https://meta.discourse.org/t/502-gateway-error-on-nginx/147172 "2020-04-07T19:13:56Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [7 أبريل 2020، 7:13م UTC](https://meta.discourse.org/t/502-gateway-error-on-nginx/147172/1 "2020-04-07T19:13:56Z")

</div>

**مُحَلَّ:** تعطيل خادم nginx، وتشغيل discourse-setup، وإعادة تمكين خادم nginx وإعادة بناء التطبيق.

مرحبًا بك. أحاول تثبيت Discourse وفقًا [لهذا الدليل](https://meta.discourse.org/t/running-other-websites-on-the-same-machine-as-discourse/).

هذا هو ملف app.yml المعدّل الخاص بي (نُسخ من مجلدات discourse وتم تعديله وفقًا للدلائل):

> ```
> templates:
> - "templates/postgres.template.yml"
> - "templates/redis.template.yml"
> - "templates/web.template.yml"
> - "templates/web.ratelimited.template.yml"
> - "templates/web.socketed.template.yml"
> ## قم بإلغاء التعليق عن هذين السطرين إذا كنت ترغب في إضافة Lets Encrypt (https)
> # - "templates/web.ssl.template.yml"
> # - "templates/web.letsencrypt.ssl.template.yml"
> 
> ## ما هي منافذ TCP/IP التي يجب أن يعرضها هذا الحاوية؟
> ## إذا كنت تريد أن يشارك Discourse منفذًا مع خادم ويب آخر مثل Apache أو nginx،
> ## راجع https://meta.discourse.org/t/17247 للحصول على التفاصيل
> expose:
> # - "80:80" # http
> # - "2222:22"
> # - "443:443" # https
> 
> ```

هذا هو كتلة nginx في ملف discourse.conf:  
server {

> ```
> server_name forum.myhost; #
> listen [::]:443 ssl http2 ipv6only=on; # تم إدارتها بواسطة Certbot
> listen 443 ssl http2; # تم إدارتها بواسطة Certbot
> ssl_certificate /etc/letsencrypt/live/forum.myhost/fullchain.pem; # تم إدارتها بواسطة Certbot
> ssl_certificate_key /etc/letsencrypt/live/forum.myhost/privkey.pem; # تم إدارتها بواسطة Certbot
> include /etc/letsencrypt/options-ssl-nginx.conf; # تم إدارتها بواسطة Certbot
> ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # تم إدارتها بواسطة Certbot
> ssl on;
> http2_idle_timeout 5m; # تم رفعه من الافتراضي 3m;
> 
> location / {
> proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;
> proxy_set_header Host $http_host;
> proxy_http_version 1.1;
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
> proxy_set_header X-Forwarded-Proto https;
> proxy_set_header X-Real-IP $remote_addr;
> }
> }
> server {
> if ($host = forum.myhost) {
> return 301 https://$host$request_uri;
> } # تم إدارتها بواسطة Certbot
> 
> server_name www.forum.myhost;
> return 301 $scheme://forum.myhost$request_uri;
> 
> listen 80;
> listen [::]:80;
> 
> server_name forum.myhost;
> return 404; # تم إدارتها بواسطة Certbot
> }
> 
> ```

يعمل الخادم مع SSL (تم تثبيت Certbot) ويعيد توجيه http إلى https في النطاق الأساسي، لكن نطاق المنتدى يُظهر خطأ 502 Gateway. أنا أستخدم Cloudflare (بدون تفعيل خيارات الأداء أو الأمان).

أي نوع من المساعدة سيكون مُقدَّرًا جدًا. لا يمكنني تنفيذ discourse-setup لأنه يظهر: “Google: “open ports YOUR CLOUD SERVICE” للحصول على معلومات لحل هذه المشكلة.”

تم التحقق من جدار الحماية أيضًا.

~~ **تعديل:** ربما تكون هناك مشكلة في هذا السطر؟ (لا أرى هذا الملف في المجلد)  
 ` proxy_pass http://unix:/var/discourse/shared/standalone/nginx.http.sock;`~~

---

<div class="post-metadata">

### Author: ![Stephen](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/stephen/32/95011_2.png) [@Stephen](https://meta.discourse.org/u/Stephen)
#### Post date: [7 أبريل 2020، 7:36م UTC](https://meta.discourse.org/t/502-gateway-error-on-nginx/147172/2 "2020-04-07T19:36:38Z")

</div>

لماذا تستخدم nginx كوسيط؟

هل توجد مواقع ويب أخرى على هذا الخادم؟

---

<div class="post-metadata">

### Author: ![satonotdead](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/satonotdead/32/447830_2.png) [@satonotdead](https://meta.discourse.org/u/satonotdead)
#### Post date: [7 أبريل 2020، 7:38م UTC](https://meta.discourse.org/t/502-gateway-error-on-nginx/147172/3 "2020-04-07T19:38:26Z")

</div>

نعم ستيفن، أنا أستخدم nginx ولدي خطط لرفع موقع Drupal. يعمل النطاق الافتراضي مع SSL كما ذكرت، لكن نطاق المنتدى الفرعي يظهر خطأ 502 gateway.

حسناً، توقفت عن تشغيل nginx في الخادم الخاص بي، وعمل discourse-setup، لكنني أرى الآن رسالة الخطأ هذه:

> تمكين Let’s Encrypt  
> ملف web.ssl.template.yml غير مفعل – هل كان مفعلًا مسبقًا؟  
> ملف letsencrypt.ssl.template.yml غير مفعل – هل كان مفعلًا مسبقًا؟
> 
> للأسف، حدث خطأ أثناء التغيير
> 
> -d قد يحدث هذا إذا قمت بإجراء تغييرات غير متوقعة.

أنا حقًا لا أعرف ما إذا كنت بحاجة لاستخدام Let’s Encrypt من Discourse أم من الخارج إذا كان مثبتًا على خادمي.

شكرًا لقراءتك.

**آخر تعديل:** لقد بدأت خادم nginx للتو، ويعمل النطاق الأساسي والنطاق الثانوي (مع الاحتفاظ بخدمة Let’s Encrypt من Certbot في مثيل Discourse)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [7 مايو 2020، 7:38م UTC](https://meta.discourse.org/t/502-gateway-error-on-nginx/147172/4 "2020-05-07T19:38:28Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
