ColdFusion 10 + IIS:不存在的URL是CFM文件。执行404页面后检索原始网址 [英] ColdFusion 10 + IIS: Non-existant URLs that are CFM files. Retrieving original URL after executing 404 page

查看:221
本文介绍了ColdFusion 10 + IIS:不存在的URL是CFM文件。执行404页面后检索原始网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的服务器设置如下:




  • Windows 2012 R2

  • Coldfusion 10, Enterprise

  • IIS,使用自定义404页面配置(在服务器上执行)



页面(CFM文件)处理缺少的URL,并针对数据库中的自定义URL进行检查。如果发现匹配,它将显示相关数据。当自定义URL映射到不存在的CFM文件时,会出现此问题;



/home/map.cfm(不是真正的文件或目录)

用户请求此URL,服务器会看到它是一个CFM文件,并正确地将其传递给ColdFusion(通过ISAPI重定向)。 Tomcat看到这个文件实际上不存在,并返回404。IIS看到这个404消息并执行自定义错误页面(/errors/404.cfm)。



生成的CGI变量不允许我们检索原始URL(将其映射到数据库中的虚拟URL),通常作为CGI.QUERY_STRING变量的一部分提供。



有任何方法可以保留最初请求的URL(如果有的话)在Tomcat为该页面返回404错误之后)?



由Thomas Gorgolione启发的解决方案



如果怀疑,问题总是归结到转发到ISAPI_REDIRECT模块的请求,即使有问题的文件不存在。



Thomas建议,一个优雅的解决方案是利用重写来检查文件/目录是否真的存在,然后传递给ISAPI_REDIRECT模块。



虽然Thomas建议的软件可以做到这一点,但我无法在64位Windows 2012 R2机器上安装。然而,我已经管理,以利用IIS8(可能更早的版本)包含的URL重写模块。



请参阅我的web.config条目下面提供一个解决方案。

 <?xml version =1.0encoding =UTF-8?& 
< configuration>
< system.webServer>
< httpErrors>
< remove statusCode =404subStatusCode = - 1/>
< / httpErrors>
< rewrite>
< rules>
< rule name =404 HTTP>
< match url =(。*)/>
< conditions>
< add input ={REQUEST_URI}pattern =CFFileServlet /(.*)negate =true/>
< add input ={REQUEST_FILENAME}matchType =IsFilenegate =true/>
< add input ={REQUEST_FILENAME}matchType =IsDirectorynegate =true/>
< add input ={SERVER_PORT_SECURE}pattern =0/>
< / conditions>
< action type =Rewriteurl =/404.cfm?404;http://{HTTP_HOST}:{SERVER_PORT}{REQUEST_URI}/>
< / rule>
< rule name =404 HTTPS>
< match url =(。*)/>
< conditions>
< add input ={REQUEST_URI}pattern =CFFileServlet /(.*)negate =true/>
< add input ={REQUEST_FILENAME}matchType =IsFilenegate =true/>
< add input ={REQUEST_FILENAME}matchType =IsDirectorynegate =true/>
< add input ={SERVER_PORT_SECURE}pattern =1/>
< / conditions>
< action type =Rewriteurl =/404.cfm?404;https://{HTTP_HOST}:{SERVER_PORT}{REQUEST_URI}/>
< / rule>
< / rules>
< / rewrite>
< /system.webServer>
< / configuration>

上述配置文件同时考虑HTTP和HTTPS请求。它还会考虑CFFileServlet目录,ColdFusion用于托管临时映像和资产。如果网址以此目录开头,则会作为正常请求传递。



感谢您输入所有人。

解决方案

注意:上面的问题也包含了解决方案。



Coldfusion连接器出现错误。我会向Adobe发布错误报告( https://bugbase.adobe.com/ )。我有一个解决方法。我有同样的问题,但我使用IIRF(Ionic IIS重定向器 - http://iirf.codeplex.com/),我发现了一种方法来避免现在的错误:


  1. 在IIS / Coldfusion中删除任何以前的404文件配置

  2. 在IirfGlobal.ini文件中(通常位于C:\Windows \System32\inetsrv\rrf),添加以下行:

      RewriteFilterPriority HIGH 



    这将允许IIRF处理404请求,甚至打到ColdFusion / Tomcat。


  3. 在网站特定的Iirf.ini(通常您在您的网络文件的根文件夹中创建一个 - 详细信息请参阅IIRF文档),添加以下规则:

      RewriteCond%{SCRIPT_TRANSLATED}!-f 
    RewriteCond%{SCRIPT_TRANSLATED}!-d
    RewriteRule ^(。+)$ page_to_redirect_to.cfm? 404; $ 1 [L]

    这会将所有不存在的文件/目录重定向到page_to_redirect_to。


  4. 编辑:添加了以下步骤:进入IIS管理器并选择服务器或配置为使用IIRF的网站,然后进入ISAPI过滤器部分。点击查看有序列表,然后将IIRF过滤器向上移动到顶部。


只是向Adobe发布了一个错误。请参见 https://bugbase.adobe.com/index.cfm?event= bug& id = 3630245



希望有所帮助。


We have a server setup as follows:

  • Windows 2012 R2
  • Coldfusion 10, Enterprise
  • IIS, configure with custom 404 page (execute on server)

The custom 404 page (a CFM file) handles missing URLs and checks them against custom URLs in the database. If it finds a match, it will display the relevant data. The problem occurs when the custom URL maps to a non-existant CFM file; for example.

/home/map.cfm (not a real file or directory)

Now, when a user requests this URL, the server sees that it is a CFM file and correctly passes it to ColdFusion (via the ISAPI redirect). Tomcat sees that this file does not actually exist, and returns a 404. IIS sees this 404 message and executes the custom error page (/errors/404.cfm).

The resulting CGI variables do not infact allow us to retrieve the original URL (to map it to a virtual URL in the database), usually provided as part of the CGI.QUERY_STRING variable. Instead, the QUERY_STRING variable contains the path to the 'isapi_rewrite.dll' file, in the 'jakarta' directory.

Is there any way to retain the originally requested URL (of a CFM file), after Tomcat has returned a 404 error for said page?

Solution, put together by myself, inspired by Thomas Gorgolione

As suspected, the issue invariably came down to the request being forwarded to the ISAPI_REDIRECT module, even if the file in question did not exist.

As Thomas suggested, an elegant solution is to utilize rewrites to check that the file / directory actually exists, before passing it through to the ISAPI_REDIRECT module.

While the software Thomas suggested would of done the trick, I was unable to get it to install on a 64bit Windows 2012 R2 machine. I've managed however to fall back to utilize the URL Rewrite module included with IIS8 (and possibly earlier versions).

See my web.config entry below that provides a solution.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors>
            <remove statusCode="404" subStatusCode="-1" />
        </httpErrors>
        <rewrite>
            <rules>
                <rule name="404 HTTP">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern="CFFileServlet/(.*)" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{SERVER_PORT_SECURE}" pattern="0" />
                    </conditions>
                    <action type="Rewrite" url="/404.cfm?404;http://{HTTP_HOST}:{SERVER_PORT}{REQUEST_URI}" />
                </rule>
                <rule name="404 HTTPS">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{REQUEST_URI}" pattern="CFFileServlet/(.*)" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                        <add input="{SERVER_PORT_SECURE}" pattern="1" />
                    </conditions>
                    <action type="Rewrite" url="/404.cfm?404;https://{HTTP_HOST}:{SERVER_PORT}{REQUEST_URI}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

The above configuration file takes into account both HTTP and HTTPS requests. It will also take into account the the CFFileServlet directory, which ColdFusion uses to host temporary images and assets. If the URL starts with this directory, it will be passed on as a normal request.

Thanks for your input everyone.

解决方案

NOTE: Question above includes a solution as well.

I think this is an error with the Coldfusion Connector. I would post a bug report to Adobe (https://bugbase.adobe.com/). I do have a workaround though. I have the same issue, but I use IIRF (Ionic IIS Redirector - http://iirf.codeplex.com/), and I found a way to use that to avoid the bug for now:

  1. Remove any previous 404 file configuration in IIS/Coldfusion
  2. Install IIRF normally, according to it's install instructions.
  3. In the IirfGlobal.ini file (normally located in C:\Windows\System32\inetsrv\IIRF), add the following line:

    RewriteFilterPriority HIGH
    

    This will allow IIRF to handle 404 requests before it even hits ColdFusion/Tomcat.

  4. In the site-specific Iirf.ini (usually you create one in the root folder of your web files -- see the IIRF docs for details), add the following rules:

    RewriteCond %{SCRIPT_TRANSLATED} !-f
    RewriteCond %{SCRIPT_TRANSLATED} !-d
    RewriteRule ^(.+)$ page_to_redirect_to.cfm?404;$1 [L]
    

    That will redirect all files/directories that don't exist to page_to_redirect_to.cfm, and add the 404 query string like normal.

  5. EDIT: Added a following step: Go into the IIS Manager and select either the server or the Web Site that was configured to use IIRF, then go into the ISAPI Filters section. Click on "View Ordered List", then move the IIRF filter up to the top.

EDIT 2: Just posted a bug to Adobe. See https://bugbase.adobe.com/index.cfm?event=bug&id=3630245

Hope that helps.

这篇关于ColdFusion 10 + IIS:不存在的URL是CFM文件。执行404页面后检索原始网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆