質問

OK apache IBM HTTP Server WAS 6.1 のセットアップ

certs が正しくインストールされており、 http および https ページを正常にロードできます。

https による j_security_check 認証が成功した後、現在承認されているページ(およびそれ以降のすべてのページ)を http としてロードします。

このすべてを mod_rewrite で動作させたいのは、Webサーバーで本当に簡単に実行できるはずのアプリケーションコードを変更したくないからです。

これは機能すると思いますが、機能しません。 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] は、実行されたルールを要求で実行し、それに応じてリダイレクトする最後のルールに強制することを知っています。

少しグーグルで調べたところ、この小さな宝石が見つかりました。

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>

マシンのIPと port 443 を指す単一の virtualhost 宣言にInherit宣言を追加しても、少しも役に立ちませんでした。

アプリサーバーがそれぞれ 9080 9443 で通信することはわかりましたが、Webサーバーに単一の virtualhost が見つかりません httpd.conf

認証されていないときにさまざまな書き換えルールを使用していくつかのテストを行い、 mod rewrite コードが機能することを確認しました。

では、認証後にwebsphereでmod rewriteを使用するにはどうすればよいですか

Webサーバーは認証されていないリクエストにのみ使用され、その後何らかのブラックボックスコンテナが何らかの形ですべてを提供するようです。

役に立ちましたか?

解決

これは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>

他のヒント

ワイルドな推測:2番目の論理ORはANDにする必要があります(つまり、[OR]がなく、RewriteCondのデフォルトはANDです)

RewriteCond %{THE_REQUEST} !login\.jsp.*action=init
RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top