The above Discourse cookie string is 1,962 characters long!
For comparison, the cookie header sent to my Mediawiki site is 122 characters long, including my username, user id, and session id.
The Mediawiki session id is 32 characters long, but Discourse appears to have two session ids: rack.session is 813 characters long and _forum_session is 1,075 characters long. Please help me to understand why a simple uid needs to be so long. Can I configure Discourse to use a shorter session uid? Does such a request make sense?
What is stored in that string? Is it possible to make it smaller?
Specifically, what component of the Discourse software is rack.session used for? And what is _forum_session used for?
Of course I can just bump up the nginx config limits, but I’d like to keep them reasonably low unless there’s a strong requirement to increase them.
I support auditing our session cookies and maybe just moving to default use our redis backed session that auto expires which is better anyway. @david any thoughts here?
Depends, plugins that use session heavily can be impacted, its also a hygiene thing, nicer to keep all this secret info on the server instead of encrypted on the client.
Yikes, this tuning was done intentionally for security; it’s not a “badly configured” proxy. Tuning down the following nginx directives is commonly done as part of hardening nginx (to address availability, rate limiting, DOS, etc):
The settings we use in our nginx config work fine on all our existing sites. The problem here appears to be that Discourse stores unnecessary client data in the cookie, where imho the only thing stored in the cookie should be just a few unique identifiers that the server can use to access that data server-side.
Thanks Sam. By “moving to default use redis” are you suggesting that it’s currently possible to move the data stored in the session cookie to redis with a configuration change? Or would moving this data out of the session cookie to the server necessarily require a code change?
ملاحظة: اضطررت أيضًا إلى تجاوز تعليمات large_client_header_buffers في إعدادات nginx المشددة الخاصة بي لكي يعمل Discourse بشكل صحيح.
على وجه التحديد، أستخدم large_client_header_buffers 2 1k في إعدادات nginx لجميع مواقع أخرى. لكن هذا يتسبب في ظهور خطأ 414 Request-URI Too Large من /admin/reports/bulk?XYZ — حيث أن XYZ يتكون فعليًا من 1,019 حرفًا!
تم حل هذه المشكلة عن طريق ضبط large_client_header_buffers 4 8k; في كتلة server{} الخاصة بإعدادات nginx الخاصة بـ Discourse، مما يتجاوز التعليمات العامة ويعيد القيمة الافتراضية لهذه التعليمات لـ Discourse.
تحسينًا للتوافقية بين تثبيتات Discourse عبر خوادم الويب المشددة الشائعة وجدران الحماية الشبكية وجدران حماية تطبيقات الويب، أحث مطوري Discourse على النظر في استخدام طريقة POST لمثل هذه سلاسل الاستعلام الطويلة.
بالنسبة لشخص ليس مهندس الواجهة الخلفية، ما هو الحل لهذه المشكلة؟
نتلقى الكثير من التقارير حول هذا الخطأ على مدار الشهر الماضي في منتدى Webflow. يوصي الزائر بمسح ملفات تعريف الارتباط/الذاكرة المؤقتة أو استخدام وضع التصفح المتخفي، وقد نجح ذلك ولكنه ليس مثاليًا.