HTTP إلى HTTPS إلى HTTP باستخدام خادم Mod_Rewrite و IBM HTTP
-
05-07-2019 - |
سؤال
طيب لدي apache IBM HTTP Server WAS 6.1
اقامة
لدي بلدي certs
تم تثبيته بشكل صحيح ويمكن تحميله بنجاح http
و https
الصفحات.
بعد ناجحة j_security_check
المصادقة عبر https
, ، أريد أن يتم تحميل الصفحة المعتمدة الآن (وجميع الصفحات اللاحقة) http
.
اريد كل هذا أن يعمل مع mod_rewrite
لأنني لا أرغب في تغيير رمز التطبيق لشيء يجب أن يكون بسيطًا في خادم الويب.
أعتقد أن هذا سيعمل ولكنه لا يعمل ويخشى ذلك بسبب j_security_check
هو تجاوز mod_rewrite
بطريقة ما.
RewriteCond %{HTTPS} =off
RewriteCond %{THE_REQUEST} login\.jsp.*action=init [OR]
RewriteCond %{THE_REQUEST} login\.jsp.*action=submit
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L] <<-- this rule is working
RewriteCond %{HTTPS} =on
RewriteCond %{THE_REQUEST} !login\.jsp.*action=init [OR]
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
RewriteRule .* http://%{SERVER_NAME}%{REQUEST_URI} [R,L] <--- this rule is not working or the condition is not returning true
أنا أعرف ال [R,L]
سوف يجبر القاعدة المنفذة على أن تكون القاعدة الأخيرة التي يتم تشغيلها بناءً على طلب وإعادة التوجيه وفقًا لذلك.
لقد وجدت هذه الجوهرة الصغيرة بعد القليل من Google.
mod_rewrite: My rules are ignored. Nothing is written to the rewrite log.
The most common cause of this is placing mod_rewrite directives at global scope (outside of any VirtualHost containers) but expecting the directives to apply to requests which were matched by a VirtualHost container.
In this example, the mod_rewrite configuration will be ignored for requests which are received on port 443:
RewriteEngine On
RewriteRule ^index.htm$ index.html
<VirtualHost *:443>
existing vhost directives
</VirtualHost>
Unlike most configurable features, the mod_rewrite configuration is not inherited by default within a <VirtualHost > container. To have global mod_rewrite directives apply to a VirtualHost, add these two extra directives to the VirtualHost container:
<VirtualHost *:443>
existing vhost directives
RewriteEngine On
RewriteOptions Inherit
</VirtualHost>
إضافة إعلان الوراثة إلى أغنيتي الفردية virtualhost
الإعلان الذي يشير إلى IP الجهاز و port 443
لم يساعد قليلا.
الآن أعلم أن خادم التطبيق الخاص بي يتواصل 9080
و 9443
على التوالي ولكن لا يمكنني العثور على واحد virtualhost
في خادم الويب httpd.conf
.
لقد أجريت بعض الاختبارات باستخدام قواعد إعادة كتابة مختلفة أثناء عدم المصادقة ورأيت ذلك mod rewrite
عمل الكود ..
إذن: كيف أجعل WebSphere تستخدم إعادة كتابة Mod بعد المصادقة؟
يبدو الأمر كما لو أن خادم الويب يستخدم فقط للطلبات غير المصادقة وبعد ذلك تخدم بعض حاوية Blackbox كل شيء بطريقة أو بأخرى.
المحلول
هذا هو الحل لـ HTTP إلى HTTPS إلى HTTP
عليك أن تضع الحالة وقاعدة إعادة الكتابة في المضيف الظاهري كما قال القطب الشمالي ولكن لسبب ما لا يريد الميراث العمل.
RewriteEngine on
RewriteCond %{HTTPS} !=on
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /path/login\.jsp\ HTTP/1\.1
RewriteRule .* https://%{SERVER_NAME}%{REQUEST_URI} [R,L]
<VirtualHost 000.000.000.000:443>
ServerName servername
ServerAlias url.com machinename
DocumentRoot d:/ibmhttpserver61/htdocs/en_US
ErrorLog d:/ibmhttpserver61/logs/secerr.log
TransferLog d:/ibmhttpserver61/logs/sectrans.log
SSLEnable
Keyfile d:/ibmhttpserver61/ssl/ctxroot.kdb
SSLV2Timeout 100
SSLV3Timeout 1000
RewriteEngine On
RewriteCond %{REQUEST_URI} /path/secure/index.jsf
RewriteRule ^(.*)$ http://url/path/secure/index.jsf [R,L]
</VirtualHost>
نصائح أخرى
Wild Guess: هل يجب أن يكون المنطق الثاني أو (لا يوجد [أو] وإعادة كتابة الافتراضيات إلى و)؟
RewriteCond %{THE_REQUEST} !login\.jsp.*action=init
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit