反向代理总结-reverse-proxy-with-url-rewrite
iis 反向代理 :
1. 微软文档 https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing
2 示例:实现反向代理,修改响应内容 css js image 302跳转等。
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<urlCompression doStaticCompression="false" doDynamicCompression="false" />
<rewrite>
<!-- 请求代理 -->
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="http://localhost:3000/{R:1}" />
</rule>
</rules>
<outboundRules>
<!-- js css 图片路径修改 -->
<rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" stopProcessing="true">
<match filterByTags="A, Area, Base, Form, Frame, Head, IFrame, Img, Input, Link, Script" pattern="^/(.*)" />
<action type="Rewrite" value="/gitserver{R:0}" />
<conditions>
</conditions>
</rule>
<!-- 302跳转 -->
<rule name="Http302" preCondition="Http302">
<match serverVariable="RESPONSE_LOCATION" pattern=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="^/([^/]+)/.*" />
<add input="{RESPONSE_LOCATION}" pattern="^http[s]?://.*" negate="true" />
</conditions>
<action type="Rewrite" value="/{C:1}{R:0}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
<!-- 302跳转 -->
<preCondition name="Http302">
<add input="{RESPONSE_STATUS}" pattern="302" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
</system.webServer>
</configuration>
3、相关参考
https://www.cnblogs.com/shamork/p/config_IIS_like_nginx.html
http://blog.bossma.cn/dotnet/iis-reserve-proxy-redirect-302-but-get-404-solution/
如果您认为这篇文章还不错或者有所收获,可以点击右下角的【推荐】按钮,因为你的支持是我继续写作,分享的最大动力!
作者: ( 白蚁 )
来源:https://www.cnblogs.com/xyyie
声明: 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。如果您发现博客中出现了错误,或者有更好的建议、想法,请及时与我联系!!如果想找我私下交流,可以私信或者加我QQ。
作者: ( 白蚁 )
来源:https://www.cnblogs.com/xyyie
声明: 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。如果您发现博客中出现了错误,或者有更好的建议、想法,请及时与我联系!!如果想找我私下交流,可以私信或者加我QQ。

浙公网安备 33010602011771号