【问题标题】:http to https to http using mod_rewrite and IBM http serverhttp 到 https 到 http 使用 mod_rewrite 和 IBM http 服务器
【发布时间】:2010-09-20 01:22:42
【问题描述】:

好的,我有一个apache IBM HTTP Server WAS 6.1 设置

我的certs 已正确安装,并且可以成功加载httphttps 页面。

通过https 成功进行j_security_check 身份验证后,我希望现在授权的页面(以及所有后续页面)加载为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] 将强制执行的规则成为对请求运行的最后一条规则并相应地重定向。

我在谷歌搜索后发现了这颗小宝石。

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>

将 Inherit 声明添加到指向机器 ip 和 port 443 的单个 virtualhost 声明并没有帮助。

现在我知道我的应用服务器分别在 90809443 上进行通信,但我在 Web 服务器 httpd.conf 中找不到单个 virtualhost

我在未经身份验证的情况下使用不同的重写规则进行了一些测试,发现我的mod rewrite 代码有效..

那么:如何让 websphere 在认证后使用 mod 重写?

这就像网络服务器仅用于未经身份验证的请求,然后某个黑盒容器以某种方式提供所有内容。

【问题讨论】:

    标签: mod-rewrite ssl ibmhttpserver


    【解决方案1】:

    猜测:第二个逻辑 OR 是否应该是 AND(即没有 [OR] 并且 RewriteCond 默认为 AND)?

    RewriteCond %{THE_REQUEST} !login\.jsp.*action=init
    RewriteCond %{THE_REQUEST} !login\.jsp.*action=submit
    

    【讨论】:

      【解决方案2】:

      这是http to https to 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>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-08-12
        • 2019-07-01
        • 1970-01-01
        • 2013-07-05
        • 1970-01-01
        • 2017-05-21
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多