如何在IIS重写模块中设置代理头(相当于nginx proxy_pass)

sxissh06  于 5个月前  发布在  Nginx
关注(0)|答案(1)|浏览(70)

如何在IIS重写模块中设置代理头
在nginx中,我们有类似于

server {
    location / {
        # we add a custom-host parameter in the header
        # which corresponds to the domain for which the certificates can be viewed
      proxy_set_header custom-host your-domain.com;
      proxy_pass https://certificate-testsite.com;
    }
}

字符串
什么是相当于在IIS中。我们如何在IIS中设置代理头(自定义主机)?我已经尝试使用URL重写模块,并设置serverVariables如下:

<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="https://certificate-testsite.com/{R:1}" />
                    <serverVariables>
                        <set name="HTTP_custom_host" value="your-domain.com" />
                    </serverVariables> 
                </rule>
            </rules>
            <rewriteMaps>
                <rewriteMap name="HTTP_custom_host" />
            </rewriteMaps>       
</rewrite>
</system.webServer>
</configuration>


但那没用。谢谢

wlp8pajw

wlp8pajw1#

IIS和NGINX是不同的Web服务器,配置语法和功能不同。如果你想在IIS上实现类似的功能,你可以考虑使用ARR模块和URL重写模块。ARR允许你启用反向代理,URL重写模块允许你创建反向代理规则和设置服务器变量。
在IIS中,serverVariables集合允许您访问特定于服务器的变量。但是,请务必注意,在服务器环境中对服务器变量所做的更改可能不会直接反映在客户端浏览器中可见的请求标头中。
参考链接:
Setting HTTP request headers and IIS server variables
Reverse Proxy with URL Rewrite v2 and Application Request Routing
Adding a custom header to ARR requests

相关问题