IIS重写以向每个请求添加查询变量

时间:2018-04-11 13:04:31

标签: iis url-rewriting

我对配置IIS几乎一无所知,但已经分配了一项任务,即将查询变量添加到通过用作Web代理的IIS服务器发出的每个请求。

我们查找域之后的第一个路径段是固定字符串的任何URL,例如/ bongo /并将其重定向到后端服务器。我有它正在努力执行重定向,但我很确定我有很多垃圾,我不需要在以下配置中,我从另一个答案得到。

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
        <rewrite> 
            <rules> 
                <rule name="Route the requests for bongo Player" stopProcessing="true"> 
                    <match url="^bongo/(.*)" /> 
                    <conditions> 
                        <add input="{CACHE_URL}" pattern="^(https?)://" /> 
                    </conditions> 
                    <action type="Rewrite" url="https://bongo.fse.companyinc.com/bongo/{R:1}" /> 
                    <serverVariables> 
                        <set name="HTTP_ACCEPT_ENCODING" value="" /> 
                    </serverVariables> 
                </rule> 
            </rules> 
            <outboundRules> 
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1"> 
                    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^http(s)?://bongo.fse.companyinc.com/bongo/(.*)" /> 
                    <action type="Rewrite" value="/{R:2}" /> 
                </rule> 
                <rule name="RewriteRelativePaths" preCondition="ResponseIsHtml1"> 
                    <match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/bongo/(.*)" negate="false" /> 
                    <action type="Rewrite" value="/{R:1}" /> 
                </rule> 
                <preConditions> 
                    <preCondition name="ResponseIsHtml1"> 
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" /> 
                    </preCondition> 
                </preConditions> 
            </outboundRules> 
        </rewrite>
        <tracing>
            <traceFailedRequests>
                <add path="*">
                    <traceAreas>
                        <add provider="ASP" verbosity="Verbose" />
                        <add provider="ASPNET" areas="Infrastructure,Module,Page,AppServices" verbosity="Verbose" />
                        <add provider="ISAPI Extension" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket,Rewrite,RequestRouting" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions timeTaken="00:00:30" statusCodes="200-299,300-399,400-499,500-599" verbosity="Warning" />
                </add>
            </traceFailedRequests>
        </tracing> 
    </system.webServer> 
</configuration>

1)我甚至不确定我是否需要出境规则。

2)我遇到的主要问题是我想总是追加一个查询变量,是否存在现有的查询变量。我已经尝试过太多配置来列出这里,但我似乎无法在代理时附加变量。

我非常感谢任何IIS大师的帮助。

0 个答案:

没有答案